【发布时间】:2011-08-03 08:44:33
【问题描述】:
我有以下问题。在我的解决方案中,我有 2 个控制器:家庭和帐户。到目前为止一切正常。但是当我在 HomeController 上方添加 [Authorize] 时,例如
[Authorize]
public class HomeController : Controller
{
...
我明白了
System.InvalidOperationException: The partial view 'Repository' was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Account/Repository.aspx
~/Views/Account/Repository.ascx
~/Views/Shared/Repository.aspx
~/Views/Shared/Repository.ascx
~/Views/Account/Repository.cshtml
~/Views/Account/Repository.vbhtml
~/Views/Shared/Repository.cshtml
~/Views/Shared/Repository.vbhtml
部分视图存储库位于 HomeController 内,因此它的视图位于 ~/Views/Home/Repository.cshtml 中,但它被保存在共享或帐户文件夹中。正如我所说,如果 HomeController 类之上没有 [Authorize],那么一切都会按预期进行。
发生错误的代码在_Layout.cshtml中
@Html.Partial("Repository")
感谢您的帮助。
【问题讨论】:
标签: c# asp.net-mvc