简体   繁体   English

ASP.NET MVC Razor 无法在区域中找到视图

[英]ASP.NET MVC Razor cannot find views in area

URLs work correctly网址正常工作
Actions work correctly动作正常工作
the only problem is that the razor engine is just searching for view files in ~/Views and not in ~/Areas/Admin and I don't know why is that because it used to work fine唯一的问题是剃刀引擎只是在~/Views搜索视图文件,而不是在~/Areas/Admin ,我不知道为什么会这样,因为它曾经可以正常工作
It works when I fill the return view type of the action by the exact path of its view but the absolute path for views is not working当我通过其视图的确切路径填充操作的返回视图类型但视图的绝对路径不起作用时,它起作用

行政区目录

Here is one action for example but none of the actions in the admin area can call their views例如,这是一个操作,但管理区域中的所有操作都无法调用它们的视图
Even _Logout which is a partial view ib Shared cannot be called by _Layout unless using the full path甚至_Logout其为IB的局部视图Shared不能被称为_Layout除非使用全路径
Action in Controller:控制器中的动作:

        // GET: Admin/Login
        [Route("Admin/Login")]
        public ActionResult Login()
        {
            return View();
        }

Error:错误:

The view 'Login' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Default/Login.aspx
~/Views/Default/Login.ascx
~/Views/Shared/Login.aspx
~/Views/Shared/Login.ascx
~/Views/Default/Login.cshtml
~/Views/Default/Login.vbhtml
~/Views/Shared/Login.cshtml
~/Views/Shared/Login.vbhtml

Solved!解决了!
[RouteArea("Admin", AreaPrefix = "")] Was missing from top of my controller [RouteArea("Admin", AreaPrefix = "")]从我的控制器顶部丢失

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM