c# - ASP.NET MVC 3 View 引擎无法识别带有 .cshtml 的 PartialView

标签 c# asp.net-mvc asp.net-mvc-3 razor

下图显示了 Partial View GetMovieTypes.cshtml 位于 Shared 文件夹中

我在 EmployeeController 的索引 View 中使用 @Html.Partial("GetMovieTypes.cshtml") 行调用部分 View

Issue is I get Server Error when I call the Employee Controller with Index Action

The partial view '_GetMovieTypes.cshtml' was not found or no view engine supports the searched locations. The following locations were searched:

~/Areas/Staff/Views/Employee/GetMovieTypes.cshtml.cshtml

但是当我将 PartialView 重命名为 GetMovieTypes.cshtml.cshtml 时,它工作正常

为什么 ViewEngine 强制我添加 .cshtml 扩展两次

enter image description here

最佳答案

删除 .cshtml 部分:

@Html.Partial("GetMovieTypes")

关于c# - ASP.NET MVC 3 View 引擎无法识别带有 .cshtml 的 PartialView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12039080/

相关文章:

c# - .Net 中的多个 Parallel.ForEach 循环

c# - 使用 C# 处理 - 完整实现

c# - 使用 nameof() 与其父类一起检查类名以进行 MVC 验证

asp.net - 如何在复杂的嵌套对象上使用 [Bind(Include ="")] 属性?

asp.net-mvc-3 - 使用 Autofac 将属性注入(inject)到自定义 WebViewPage

c# - 如何检查给定的字符串在 Windows 下是否是合法/有效的文件名?

c# - NHibernate hql 元组结果

c# - 创建简单的 ViewModel 以在 MVC 5 中的一个 View 中显示两个数据表

c# - asp.net MVC 创建我自己的路由

wcf - 在 ASP.NET MVC 项目上使用 Unity 解决 ServiceRoute 中的依赖项