ASP.Net,如何忽略MasterPage不存在错误?

发布于 2024-09-27 13:50:44 字数 566 浏览 1 评论 0原文

我正在开发基于 ASP.Net MVC2 的 CMS 项目,我已经为我的母版页实现了 VirtualPathProviderVirtualFile ,以在数据库中使用母版页。

其工作原理如下: 我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桃酥萝莉 2024-10-04 13:50:44

我找到了另一种方法来避免使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文