To discover UrlRoute attributes on MVC Controller classes, call RouteCollectionExtensions.DiscoverMvcControllerRoutes in the Application_Start event in Globals.asax.cs. For example, you can make this call in the RegisterRoutes method generated by the Visual Studio project wizard (which is invoked by Application_Start):

public static void RegisterRoutes(RouteCollection routes)

    // discover UrlRoute attributes on MVC controller classes in the project

If you have defined one or more MVC Areas, you can discover routes added to controller methods in each Area by calling DiscoverMvcAreaRoutes extension method in the AreaRegistration.RegisterArea method of your Area:

    public override void RegisterArea(AreaRegistrationContext context)
        // discover all UrlRoute attributes on controller methods within the area

Last edited Apr 2, 2011 at 7:50 AM by ds7, version 1


No comments yet.