当我在Admin
区域内并使用属性路由映射我的路线时,它找不到视图,因为它不会查看实际区域视图文件夹,而只查看全局视图文件夹.
只有当我通过完整路径查看它然后才能显示它,否则它会抛出我的错误.
错误
The view 'Authorize' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Home/Authorize.aspx ~/Views/Home/Authorize.ascx ~/Views/Shared/Authorize.aspx ~/Views/Shared/Authorize.ascx ~/Views/Home/Authorize.cshtml ~/Views/Home/Authorize.vbhtml ~/Views/Shared/Authorize.cshtml ~/Views/Shared/Authorize.vbhtml
码
[RoutePrefix("admin")] public class HomeController : Controller { [Route] public ActionResult Index() { return View("Authorize"); // Error return View("~/Areas/Admin/Views/Home/Authorize.cshtml"); // Working } }
请注意,如果我禁用属性路由并切换回旧的路由,它将起作用.有什么方法可以解决这个问题,或者它是按照预期的方式工作的,我应该在所有方面应用完整的路径?