MVC 4 Area Routing is not working

后端 未结 6 1535
伪装坚强ぢ
伪装坚强ぢ 2021-02-14 08:09

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:27

    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

提交回复
热议问题