Razor is prettier (and is new therefore cool).
Webforms is something I am already familiar with.
Naturally I would unquestionably go for the new thing to learn - Razor. But I have heard of two disadvantages that worry me:
So what are the advantages of Razor over Webforms view engines when using ASP.NET MVC 3?
Razor is simply one of the View Engines provided. The other one provided out-of-the-box is the "old" WebForms one (you can also write your own View Engine by the way). So Razor does not have the notion of code-behind which stays within the WebForms view engine boundaries. So this kinda says it all.
ASPX View Engine is the default view engine for the ASP.NET MVC that is included with ASP.NET MVC from the beginning. Razor View Engine supports System.Web.Razor. ASPX View Engine supports System.Web.Mvc.WebFormViewEngine. In Razor View Engine we use Layouts. In ASPX View Engine we use masterPages. In Razor View Engine we use PartialPage.
ASP.NET MVC is a framework for creating web applications with either the Web Forms or Razor engine using the Model-View-Controller (MVC) pattern. ASP.NET Web Forms is a framework for creating web applications using the Web Forms render engine.
A web form view engine is the default view engine and available from the beginning of MVC. Razor has a syntax that is very compact and helps us to reduce typing. The web form view engine has syntax that is the same as an ASP.Net forms application. The Razor View Engine uses @ to render server-side content.
This has already been addressed by the following question: Does Razor syntax provide a compelling advantage in UI markup?
The Web form controls are already not very usable in Asp.Net Mvc. Since the MVC does not have the ViewState/Postback mechanism, and most controls need to use that. (Webforms: 0 Points, Razor 0 Points)
Syntax in @Razor is much prettier. (Webforms: 0 Points, Razor 1 Points)
Don't know about the performance. I think that the (one time) parsing and rendering is such a small step of the whole pipeline, this should not matter. And might be changed by future updates. (Webforms: 0 Points, Razor 0 Points)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With