开发者

Is Microsoft planning to remove MasterPages from MVC?

开发者 https://www.devze.com 2023-01-29 15:18 出处:网络
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 t开发者_开发知识库eam is trying to replace the MasterPage func

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 t开发者_开发知识库eam 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!


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.


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).


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号