在我的控制器中,我定义了:
const string KList = "list.cshtml";
我称之为行动方法:
public ActionResult All()
{
var view = Empty();
var model = new Model(); // some other code to get the model
view = PartialView(KList, model);
return view;
}
以下是这样的观点:
我得到了一个错误:
System.Web.HttpException:执行处理程
现在已经有了MVC3预览1,我们可以使用Razor (.cshtml)视图引擎了。如果没有找到视图,我会得到这个错误:
The view 'a' or its master was not found. The following locations were searched:
~/Views/Home/a.aspx
~/Views/Home/a.ascx
~/Views/Shared/a.aspx
~/Views/Shared/a.ascx
~/Views/Home/a.cshtml
~/Views/Shared/a.cshtml
如果我不打算使用.aspx/.ascx查找
我做了一个项目,其中我有一个基本的DemoController
<Export(GetType(IController))> _
<ExportMetadata("controllerName", "Demo")> _
<PartCreationPolicy(CreationPolicy.NonShared)> _
Public Class DemoController Inherits Controller
Public Function Index() As ActionResult
Return
基于这个问题,和使用代码发现的,我试图在一个单独的DLL项目中加载作为嵌入式资源的视图,而最初问题的作者说他已经成功地做到了这一点--但我无法让它工作,因为MVC视图引擎似乎正在拦截请求,并且仍然在查看视图的文件系统。例外:
Server Error in '/' Application.
The view 'Index' or its master could not be found. The following locations were searched:
~/Views/admin/Index.aspx
~/Views/admin/Index.asc