2023-02-17 415
基于这个问题这里并使用代码 here 文件系统.例外:
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’s/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的打开方法中,~/plugin/admin的虚拟路径在上面的路线中定义时,它会在应该~/plugin/admin/Index.aspx时传递.我搞砸了我的路线,或者我要期待这种情况是正确的吗?
这是一个带有可下载代码示例的文章,演示了以下:
内置WebFormsViewEngine使用VirtualPathProviders,因此如果您编写VPP并注册,则无需对视图引擎进行任何更改.
以上所述是小编给大家介绍的使用VirtualPathProvider从DLLs加载ASP.NET MVC视图,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!
原文链接:https://77isp.com/post/34263.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态