ASP.Net,如何忽略MasterPage不存在错误?
我正在开发基于 ASP.Net MVC2 的 CMS 项目,我已经为我的母版页实现了 VirtualPathProvider 和 VirtualFile ,以在数据库中使用母版页。
其工作原理如下: 我在 aspx/ascx 文件中指示 MasterPageFile。
<%@ Page MasterPageFile="/Content.master"
然后重写VirtualPathProvider.GetFile从数据库加载母版页,“/Content.master”是在数据库中搜索的关键。
一切对我来说都工作正常,除了
如果我在 VS2010 的上下文菜单中单击“构建网站”,我会收到一条错误消息“文件‘/Content.master’不存在”。
我的母版页存储在数据库中,这个错误是正常的,有没有办法让VS2010忽略这个错误?
我正在查看BuildManager相关代码,看起来很复杂。
感谢您的帮助
I am working on my CMS project based on ASP.Net MVC2, I have implemented my VirtualPathProvider and VirtualFile for my master page, to use a master page in db.
It works as below:
I indicate the MasterPageFile in the aspx/ascx file.
<%@ Page MasterPageFile="/Content.master"
Then override VirtualPathProvider.GetFile to load the master page from db, "/Content.master" is the key to search in the db.
Everything works fine for me, except
IF I click "Build Web Site" in the context menu in VS2010, I will get an error says "The file '/Content.master' does not exist."
My master page is stored in db and this error is normal, Is there a way that VS2010 can ignore this error?
I am looking into the BuildManager relative code, seems complicated.
Thank you for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了另一种方法来避免使用 MasterPageFile 属性
在 System.Web.Mvc.ViewPage/ViewMasterPage 派生类中添加自定义属性 PageTemplate
I have found another way to avoid using MasterPageFile property
Add a custom property PageTemplate in System.Web.Mvc.ViewPage/ViewMasterPage derived classes