Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Razor and ASPX?

Is there any difference between Razor and ASPX in a MVC project?

Is it just about syntax? That's what I think after reading this... Am I wrong?

like image 950
BrunoLM Avatar asked Jan 15 '11 21:01

BrunoLM


People also ask

Why use a Razor when we have aspx?

Razor has new and advance syntax that are compact, expressive and reduces typing. Web Form Engine has the same syntax like Asp.net Web Forms uses for . aspx pages. By default, Razor Engine prevents XSS attacks(Cross-Site Scripting Attacks) means it encodes the script or html tags like <,> before rendering to view.

Which view engine is better Razor or ASPX?

The Razor View Engine is a bit slower than the ASPX View Engine. Razor provides a new view engine with streamlined code for focused templating. Razor's syntax is very compact and improves readability of the markup and code. By default MVC supports ASPX (web forms) and Razor View Engine.

What is the difference between ASPX and Cshtml?

One major advantage to aspx compared to cshtml is that you can view and edit the page itself (WUSIWYG kind of) using the design tab. With cshtml files you might as well use notepad to edit your html page. You are working "in the dark". @nivs1978: I actually find this to be a down-side of it.

What is the difference between Razor view and Razor page?

The difference between them is that View Pages are Razor views that are used to provide the HTML representations (aka views) for services in much the same way View Pages work for MVC Controllers.


2 Answers

It all boils down to syntax in your webpage view, but ASPX and Razor are pretty different view engines. Razor doesn't depend on the same pipeline that ASPX does. Because of that, I'd consider Razor to be just a parsing engine.

One of the advantages of that is that you can have a Razor parser run against any string, where aspx needs an httpcontext and other heavyweight elements.

like image 183
Alan Jackson Avatar answered Sep 19 '22 21:09

Alan Jackson


I guess it does boil down to that, yes.

As you can see from the examples in the article, the syntax is very lightweight and the interpreter is quite "smart".

You can compare it to the spark view engine and see the differences between the three.

like image 27
Oded Avatar answered Sep 23 '22 21:09

Oded