基于此处的问题并使用此处找到的代码,我试图将作为嵌入式资源的视图加载到一个单独的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 我使用的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; } }这是我的路线: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute("Home", "", new {controller = "Page", action = "Index", id = "Default"}); routes.MapRoute("Default", "Page/{id}", new { controller = "Page", action = "Index", id = "" }); routes.MapRoute("Plugins", "plugin/{controller}/{action}", new { controller = "", action = "Index", id = "" }); routes.MapRoute("Error", "{*url}", new { controller = "Error", action = "ResourceNotFound404" });在我AssemblyResourceProvider,我检查,看看是否路径开始~/plugin/,然后使用该dll文件名公约plugin.{controller}.dll有什么建议么?更新:当路由的发言请求http://localhost/plugin/admin到达VirtualFileProvider时,它的末尾没有任何视图。因此,在VirtualFileProvider的Open方法~/plugin/admin中,应该按照~/plugin/admin/Index.aspx上面我的路线中的定义传递虚拟路径。我是否弄乱了路线,还是期待发生这种情况?
- 3 回答
- 0 关注
- 535 浏览
添加回答
举报
0/150
提交
取消