ASP.Net,如何忽略母版页不存在错误?

时间:2010-10-14 08:35:55

标签: asp.net master-pages virtualpathprovider

我正在开发基于ASP.Net MVC2的CMS项目,我为我的母版页实现了 VirtualPathProvider VirtualFile ,以便在db中使用母版页

它的工作原理如下: 我在aspx / ascx文件中指明了MasterPageFile。

<%@ Page MasterPageFile="/Content.master"

然后覆盖 VirtualPathProvider.GetFile 以从db加载母版页,“/ Content.master”是在db中搜索的关键。

除了

之外,一切正常

如果我在VS2010的上下文菜单中单击“构建网站”,我将收到错误消息“文件'/Content.master'不存在。”

我的母版页存储在db中,这个错误是正常的,有没有办法让VS2010可以忽略这个错误?

我正在查看BuildManager相关代码,看起来很复杂。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我找到了另一种避免使用MasterPageFile属性的方法

在System.Web.Mvc.ViewPage / ViewMasterPage派生类中添加自定义属性PageTemplate