我有一个 View ,我尝试使用以下代码包含部分内容:
<div>
@Html.Partial("_LatestLog")
</div>
它会导致错误并显示以下消息
Message: The partial view '_LatestLog.cshtml' was not found or no view engine supports the searched locations. The following locations were searched:
~/Areas/Primary/Views/PrimaryPersonnelRoleWithAuthority/_LatestLog.aspx
~/Areas/Primary/Views/PrimaryPersonnelRoleWithAuthority/_LatestLog.ascx
~/Areas/Primary/Views/Shared/_LatestLog.aspx
~/Areas/Primary/Views/Shared/_LatestLog.ascx
~/Views/PrimaryPersonnelRoleWithAuthority/_LatestLog.aspx
我希望它能在同一文件夹中找到文件 _LatestLog.cshtml,有什么问题吗?
最佳答案
实际上 _LatestLog
部分 View 在 Primary
区域不可用。
你可以在这里做三件事:
- 在该主要区域创建局部 View ;
- 在共享中创建局部 View ;
或者您可以在其他区域保留一个局部 View ,并通过如下路径调用该局部 View :
@Html.Partial("~/Areas/Primary/Views/PrimaryPersonnelRoleWithAuthority/_LatestLog.cshtml")
关于c# - Html.Partial 搜索 aspx 而不是 cshtml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29746346/