BrunoLM
BrunoLM

Reputation: 100331

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?

Upvotes: 40

Views: 54001

Answers (6)

Sandeep Shekhawat
Sandeep Shekhawat

Reputation: 695

  1. By default, Razor Engine prevents XSS attacks(Cross-Site Scripting Attacks) means it encodes the script or html tags like <,> before rendering to view.
  2. Razor Engine support TDD (Test Driven Development) since it is not depend on System.Web.UI.Page class.

Upvotes: 1

Oded
Oded

Reputation: 499002

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.

Upvotes: 19

KWallace
KWallace

Reputation: 1698

In my opinion, I think Razor is Microsoft swinging around to scoop up all the classic ASP developers they left behind when they introduced .NET. The paradigm is very similar to ASP, server side code intermingled with client side html/js. An environment which is conducive, all over again, to the "spaghetti code" dilemma.

But for long time ASP developers, such as myself, it was the straightest route to a supported platform. And I retain the absolute control of the html/js that I am accustomed to.

Edit: BTW.... I am talking about Razor as used in .cshtml. I probably should have said that .cshtml is ms swinging around.

Upvotes: 0

firefly
firefly

Reputation: 419

razor support the test driven development.....while in the web engine having the system.web.ui .page class does not support TDD. test driven development means testing the code in a way before you writ it.

Upvotes: 4

Alan Jackson
Alan Jackson

Reputation: 6511

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.

Upvotes: 24

Sean Reilly
Sean Reilly

Reputation: 21836

Razor is an alternative view engine for Asp.net MVC apps, and is implemented by entirely different code than .aspx. It's like the difference between JSP and Velocity in a Java MVC web app.

Upvotes: 4

Related Questions