asp.net – 更改视图位置
发布时间:2020-05-30 21:52:23 所属栏目:asp.Net 来源:互联网
导读:我正在开发一个MVC 2.0的网站.我想更改我网站中的View文件夹位置.我想将views文件夹保存在其他文件夹中,当我尝试这样做时,我遇到了以下错误 The view Index or its master was not found. The following locations were searched:~/Views/Search/Index.aspx~/
|
我正在开发一个MVC 2.0的网站.我想更改我网站中的View文件夹位置.我想将views文件夹保存在其他文件夹中,当我尝试这样做时,我遇到了以下错误 The view 'Index' or its master was not found. The following locations were searched: ~/Views/Search/Index.aspx ~/Views/Search/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 我的视图文件夹将在/ XYZ / ABC / Views中,而不是/ Views.请解决我的问题.我是否会遇到任何问题如果我更改默认的Views文件夹位置.我是否需要更改HTML Helper类中的任何内容,因为我对MVC一无所知,因为这是我的开始项目,我不想冒险…请帮帮我… 解决方法您需要创建一个自定义视图引擎并使用它.幸运的是,您可以从默认值继承并更改构造函数上的位置.以下是创建自己的视图引擎的指南: http://www.singingeels.com/Articles/Creating_a_Custom_View_Engine_in_ASPNET_MVC.aspx来自文章: protected void Application_Start()
{
//... other things up here.
// I want to REMOVE the ASP.NET ViewEngine...
ViewEngines.Engines.Clear();
// and then add my own :)
ViewEngines.Engines.Add(new HoTMeaTViewEngine());
}
public class HoTMeaTViewEngine : VirtualPathProviderViewEngine
{
public HoTMeaTViewEngine()
{
// This is where we tell MVC where to look for our files. This says
// to look for a file at "Views/Controller/Action.html"
base.ViewLocationFormats = new string[] { "~/Views/{1}/{0}.html" };
base.PartialViewLocationFormats = base.ViewLocationFormats;
}
} (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 何时使用ASP.NET MVC与ASP.NET Web窗体?
- 使用WCF进行ASP.NET聊天
- asp.net http服务器推送到客户端
- ASP.net RequiredFieldValidator不阻止回发
- asp.net – DropDownList的EditorTemplate
- asp.net-mvc – 在asp.net mvc中存储和检索用户的设置
- asp.net-mvc – 在ASP.NET MVC中使用控制器和用户控件设置活
- asp.net-mvc – 在asp.net MVC中授权属性和jquery AJAX
- 如何格式化带有class参数的asp.net webmethod的JSON
- asp.net-mvc – 使用带有剃刀的html选择框
推荐文章
站长推荐
- 我可以在asp.net 4.0站点中托管.net 2.0虚拟目录
- asp.net – 表单和JSON调用中的表单
- asp.net – 如何使我的Web应用程序无状态仍然做一
- asp.net-mvc – 将WebForm视图引擎标记转换为Raz
- asp.net – 从另一个域配置IIS身份验证
- asp.net – MSBuild:自动收集db迁移脚本?
- asp.net-mvc – ASP.NET MVC WebSite中的ERR_EMP
- asp-classic – 检查字符串是否以“经典ASP中的另
- asp.net-mvc – 其中Simple Injector等效于Struc
- ASP.NET MVC – 在何处放置数据库查询
热点阅读
