MVC Areas - View not found

前端 未结 8 1467
盖世英雄少女心
盖世英雄少女心 2020-12-15 08:35

I have a project that is using MVC areas. The area has the entire project in it while the main \"Views/Controllers/Models\" folders outside the Areas are empty barring a dis

8条回答
  •  一整个雨季
    2020-12-15 09:00

    Check the generated code at MyAreaAreaRegistration.cs and make sure that the controller parameter is set to your default controller, otherwise the controller will be called bot for some reason ASP.NET MVC won't search for the views at the area folder

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

提交回复
热议问题