Question

I am developing a mobile application using ASP.Net MVC4.0, JQuery Mobile, HTML5. As I am new to ASP.Net MVC, I am not sure whether to use Razor(.cshtml) or webForm(.aspx) view engine.

Can anyone suggest which view engine I can use to develop a mobile application? Performance wise which is better, the razor view-engine or webform view-engine?

Was it helpful?

Solution

I don't think there is a performance aspect.

However, I find the Razor syntax beautifully terse. The HTML is far more prominent with Razor, which is what you want when you're developing HTML views.

In various MVC frameworks, view development encourages and requires code written directly alongside markup. Because the ASPX view engine was not designed with this goal in mind, the ASP.NET team decided to build an entirely new view engine with a code-focused templating approach. The result was a more intelligent parsing engine that is able to very easily figure out where code stops and where markup begins, without the developer needing to be very explicit.

There are even open-source view engines, that you might want to look at. For example, Spark View Engine.

OTHER TIPS

Razor is the preferred View Engine for MVC, ASPX View Engine is the legacy View Engine and this option is there for backward compatibility. Here you will find a great article who explain the differences between both.

The ASPX engine is listed first. A site we are working on scaling is using only Razor views. Just having the ASPX engine before the razor engine was causing a huge amount to contention to occur when attempting to scale up the number requests. Doing this:

ViewEngines.Engines.Clear();
//Add Razor Engine
ViewEngines.Engines.Add(new RazorViewEngine());

at startup made a huge difference given that each page access was no longer looking for existence of aspx, ascx files. While it might not appear to affect performance on a single request, as you scale up and see contention and rising CPU percents, this is something one should check.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top