當我在裏面Admin
面積和使用屬性的路由不能找到視圖,因爲它看起來並不實際面積查看文件夾裏面,而是全球唯一的查看文件夾映射我的路線。mvc5屬性區域內路由找不到視圖
只有我通過全路徑進行查看,然後顯示它,否則它拋出我的錯誤。
錯誤
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
}
}
需要注意的是,如果我禁用屬性路由和切換回好老路線,將工作。有什麼方法可以解決這個問題,或者按照預期工作,我應該在我所有的領域都應用完整路徑?
可能幫助一些http://stackoverflow.com/questions/22436573/default-area-cant-find-view –