MVC 4 Area Routing is not working

后端 未结 6 997
误落风尘
误落风尘 2021-02-14 07:39

I created an empty MVC4 Application, all things are working fine, after that I add an Area to my Project Named \"Moderator\". My area routing code is like this:



        
6条回答
  •  庸人自扰
    2021-02-14 08:16

    Its better to add

    AreaRegistration.RegisterAllAreas();

    in global.asax.cs. You must place in following order.

    GlobalConfiguration.Configure(WebApiConfig.Register);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    AreaRegistration.RegisterAllAreas();
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    

    Note one things that RegisterAllAreas() should be after Registering the routes. ie. RouteConfig.RegisterRoutes(RouteTable.Routes); should be before AreaRegistration.RegisterAllAreas(); .I have tried and tested and it worked for me.

    For more info: enter link description here

提交回复
热议问题