Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
        );
    }

and Global.asax as follows:

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }

And CatalogAreaRegistration is something like this:

public class CatalogAreaRegistration : AreaRegistration
{
    public override string AreaName
    {
        get
        {
            return "Catalog";
        }
    }

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Catalog_default",
            "Catalog/{controller}/{action}/{id}",
            new { action = "Index", id = UrlParameter.Optional }
        );
    }
}

The problem is when i debug, RouteCollection routes does not include rules that are defined in the area. I used routedebugger and saw that routes collection does not consists rules of "Catalog" area. It has only rules in the RouteConfig.

I have no idea what is the problem. Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
634 views
Welcome To Ask or Share your Answers For Others

1 Answer

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%AppDataLocalMicrosoftVisualStudio
  • C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files
  • C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Files
  • PathToYourProjectobjDebug

Update :

  • AppDataLocalTempTemporary ASP.NET Files

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...