基于此處的問題并使用此處找到的代碼,我試圖將作為嵌入式資源的視圖加載到一個單獨的DLL項目中,原始問題的作者說他已經(jīng)成功做到了這一點-但我無法將其作為看來MVC視圖引擎正在攔截請求,并且仍在查看該視圖的文件系統(tǒng)。例外: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有什么建議么?更新:當路由的發(fā)言請求http://localhost/plugin/admin到達VirtualFileProvider時,它的末尾沒有任何視圖。因此,在VirtualFileProvider的Open方法~/plugin/admin中,應該按照~/plugin/admin/Index.aspx上面我的路線中的定義傳遞虛擬路徑。我是否弄亂了路線,還是期待發(fā)生這種情況?
- 3 回答
- 0 關注
- 555 瀏覽
添加回答
舉報
0/150
提交
取消