通过启用 MvcBuildViews 将视图编译到 MVC 2 Portable Area

发布于 2024-09-25 09:07:35 字数 606 浏览 7 评论 0原文

我有一个大型 .net mvc 2 项目,我们在其中使用 MvcContrib Portable Area。有一个加载许多模块(PA 模块)的主网站。

主应用程序在其 ~\Views\Shared 文件夹中包含 Site.Mater。每个模块还有自己的 Site.Master ,它继承自该主模块。

目前我们正在使用类似的东西:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" MasterPageFile="~/Views/Shared/Site.Master" %>

编译后,视图正确处理主 Site.Master,因为它是相对路径。 现在我收到了在编译期间构建视图的要求。因此,我在每个 Web PA 模块项目中启用了 MvcBuildViews = true 。

当然,我收到错误消息“/temp/Views/Shared/Site.Master is not found”

如何保持可移植区域嵌入内容并确保视图不包含错误?

有什么想法吗?

I have a big .net mvc 2 project where we are using MvcContrib Portable Area. There is a main web site which load many modules (PA modules).

The main application contains Site.Mater into its ~\Views\Shared folder. each module also has own Site.Master which inherit from that main one.

At the moment we are using something like:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" MasterPageFile="~/Views/Shared/Site.Master" %>

After compilation the view handle the main Site.Master right as it is a relative path.
Now I've received a requirement to build views during the compilation. So I've enabled MvcBuildViews = true in each web PA module project.

Of course, I'm getting errors saying "/temp/Views/Shared/Site.Master is not found".

How to keep Portable Area with content embedded and ensure that views do not contain errors?

Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

小兔几 2024-10-02 09:07:35

你不能。

我正在处理同样的问题,你不能轻易伪造文件的物理位置。

唯一的解决方案是创建一个占位符并在构建过程中删除非嵌入的占位符文件。这种技术的好处是非嵌入式资源在开发中加载速度会更快一些。

另一件需要考虑的事情是,将视图加载为嵌入式资源非常慢。让您的构建过程将集中的“通用”视图移至本地项目将为您的用户带来更好的性能。

You can't.

I'm dealing with this same issue and you can't fake the physical location of a file easily.

The only solution is to make a placeholder and removing the non-embedded placeholder file as part of the build process. The benefit of this technique is the non-embedded resource will load a bit faster in development.

Another thing to consider is that loading your views as embedded resources is pretty slow. Having your build process move the centralized "common" views up to the local project will result in better performance for your users.

甜心 2024-10-02 09:07:35

如果您只是想确保一切正常,您可以使用 Watin 并编写一些即将进行的单元测试检查这个

in case you just want to make sure that everything works fine you could use Watin and write some unit tests that are going to check this

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