Initialization

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)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    // discover UrlRoute attributes on MVC controller classes in the project
    routes.DiscoverMvcControllerRoutes();
}


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
        context.DiscoverMvcAreaRoutes("admin");
    }


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

Comments

No comments yet.