基于这个问题,在这里和使用代码发现在这里,我试图加载嵌入资源在一个单独的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.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/App/Views/admin/Index.aspx
~/App/Views/admin/Index.ascx
~/App/Views/Shared/Index.aspx
~/App/Views/Shared/Index.ascx
Run Code Online (Sandbox Code Playgroud)
我使用的是CustomViewEngine像Rob Connery的/ App结构,如下所示:
public class CustomViewEngine : WebFormViewEngine
{
public CustomViewEngine()
{
MasterLocationFormats = new[] {
"~/App/Views/{1}/{0}.master",
"~/App/Views/Shared/{0}.master"
};
ViewLocationFormats = new[] {
"~/App/Views/{1}/{0}.aspx",
"~/App/Views/{1}/{0}.ascx",
"~/App/Views/Shared/{0}.aspx",
"~/App/Views/Shared/{0}.ascx"
};
PartialViewLocationFormats = ViewLocationFormats;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的路线:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Home", "", new {controller = "Page", action = "Index", id …Run Code Online (Sandbox Code Playgroud)