Microsoft 是否计划从 MVC 中删除 MasterPages?

发布于 2024-10-07 01:02:13 字数 376 浏览 7 评论 0原文

http://weblogs.asp .net/scottgu/archive/2010/10/22/asp-net-mvc-3-layouts.aspx

阅读完这篇文章后,MVC 团队似乎正在尝试替换 MasterPage 功能。这段代码对我来说确实看起来更干净,毫无疑问我会使用它(当我发布此代码时,MVC3 正在下载)。

您对此有何看法?我对 Webform 没有太多经验,因此我不知道 MasterPage 的一些高级功能。

感谢分享!

http://weblogs.asp.net/scottgu/archive/2010/10/22/asp-net-mvc-3-layouts.aspx

After reading a bit through the post, it seems that the MVC team is trying to replace the MasterPage functionality. This code does seem cleaner to me and I'll no doubt use it (MVC3 is downloading as I post this).

What are your thoughts on this? I don't have much experience with Webforms, so I don't know some of the more advanced features of a MasterPage.

Thanks for sharing!

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

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

发布评论

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

评论(3

困倦 2024-10-14 01:02:13

Razor 是 ASP.NET MVC 3 中的新视图引擎,因为 WebForms 视图引擎并不总是最适合 MVC,特别是在单元测试中 — 他们使用它是因为它就在那里。但它确实有效,ASP.NET WebForms 继续使用它,并且许多 ASP.NET MVC 站点已经在使用它(因为这是 MVC 1 和 2 中唯一“受祝福的”选项)。 Razor 的“布局”本质上与 WebForms 视图引擎中的“母版页”相同。

在这种情况下,“替换”可能是一个强烈的词,因为 WebForms 视图引擎继续在相关的受支持的技术中使用(WebForms;MVC 没有取代 WebForms); Razor 只是 MVC 的新替代品,类似于 NHaml 或 Spark。

如果您有使用 WebForms 视图引擎的现有 MVC 站点,我当然不会费心在 Razor 中重写它们。 ,它具有更好的语法,并且设计为独立于 ASP.NET 运行时运行,更好地使其能够在单元测试和其他场景(例如从模板生成电子邮件等)中使用。

但对于新站点来说 让事情变得更清楚一些。

Razor is new view engine in ASP.NET MVC 3, as the WebForms view engine wasn't always perhaps the best fit for MVC, particularly with unit testing--they used it because it was there. But it does work, ASP.NET WebForms continues to use it, and lots of ASP.NET MVC sites are already using it (since this was the only "blessed" option in MVC 1 and 2). Razor's "layouts" are essentially the same building block as "master pages" in the WebForms view engine.

"Replace" is probably a strong word to use in this case, since the WebForms view engine continues to be used in a related, supported technology (WebForms; MVC didn't replace WebForms); Razor is just a new alternative for MVC along the lines of NHaml or Spark.

If you have existing MVC sites using the WebForms view engine, I certainly wouldn't bother rewriting them in Razor. But for new sites, it has a nicer syntax and is designed to function independently of the ASP.NET runtime, better enabling it for use in unit testing and in other scenarios (such as generating e-mails from templates, etc.)

Hope that clears things up a bit.

风轻花落早 2024-10-14 01:02:13

布局页面是母版页的 Razor 实现。

它们本质上是相同的,我知道的唯一区别是布局页面支持可重用的帮助器(@helper)。

Layout Pages are the Razor implementation of Master Pages.

They are essentially the same thing, the only difference i know of is that Layout Pages support re-usable helpers (@helper).

格子衫的從容 2024-10-14 01:02:13

但这只是 Razor 的事情,不是吗?如果您决定使用 Web 窗体视图引擎,您仍然需要常规的 ViewMasterPage。

But it's just a Razor thing, isn't it? You would still need the regular ViewMasterPage if you decide to use Web Forms view engine.

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