AreaRegistration.RegisterAllAreas() is not Registering Rules For Area

后端 未结 2 1517
半阙折子戏
半阙折子戏 2020-12-09 12:45

I have an MVC 4 web application which consists some areas. I have a problem with the routing rules of an area named \"Catalog\". The RouteConfig.cs file is:

         


        
相关标签:
2条回答
  • 2020-12-09 13:16

    I think due to Visual Studio's caching, some of the dll's aren't compiled properly and this situation can happen. If you do, delete all temp files from following locations:

    • C:\Temp
    • C:\Users\%Username%\AppData\Local\Microsoft\VisualStudio
    • C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
    • C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
    • Path\To\Your\Project\obj\Debug

    Update :

    • AppData\Local\Temp\Temporary ASP.NET Files

    Then restart the Visual Studio. This is how i resolved.

    0 讨论(0)
  • 2020-12-09 13:17

    Just add the namespace of your controllers to the AreaRegistration:

    public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                **namespaces: new string[] { "Web.Admin.Controllers" }**
            );
        }
    
    0 讨论(0)
提交回复
热议问题