Getting error 404 not found with ASP.NET MVC Area routing

前端 未结 4 742
春和景丽
春和景丽 2021-01-02 06:46

I am having a problem with an Area route in MVC 5. When I browse to /Evernote/EvernoteAuth I get a 404 resource cannot be found error.

My area looks like this:

4条回答
  •  醉话见心
    2021-01-02 07:04

    Be careful with AreaRegistration.RegisterAllAreas(); inside Application_Start method.

    If you put AreaRegistration.RegisterAllAreas() to be last inside Application_Start that will not work.

    Put AreaRegistration.RegisterAllAreas() to be first and routing will be successfully executed..

    Example:

     protected void Application_Start(object sender, EventArgs e)
     {
            AreaRegistration.RegisterAllAreas();  //<--- Here work
    
            FilterConfig.Configure(GlobalFilters.Filters);
            RouteConfig.Configure(RouteTable.Routes);
    
            AreaRegistration.RegisterAllAreas();  //<--- Here not work
     }
    

提交回复
热议问题