As much i read about razor most of the people says that in razor application code is more readable, clean and clear but when and why it is required i mean to say is there any other purpose of Microsoft behind razor web application and mvc razor application ?
3 Answers
I believe you misunderstood the reasoning behind Razor. It's just a matter of taste what you like more. Some people didn't like the traditional aspx syntax, so they came up with Razor with its simplified syntax.
http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx
Don't believe there's anything more to it like performance aspect or something like that... It's just different.

- 13,466
- 5
- 41
- 67
-
Is it mean razor is used only for some different taste? – user1387147 Jun 07 '12 at 10:39
Razor is just syntax
Instead of writing those superfluous <% ... %>
, you simply write @...
. Executable parts of the view get automatically parsed by the Razor view engine.
That's why Razor views are in general shorter than web form views. But as @walther said it's a matter of taste, although you get hooked by Razor pretty fast and don't want to go back after some time of using it.
Application?
There's not such thing as a Razor web application. It's either Asp.net MVC application with Razor views or Asp.net web pages with Razor syntax... Each of them can be used with long existing web forms view engine as well...
Analogy
Imagine reading a magazine on paper or on an iPad. You'd read the same content, but the experience is somehow different. That's what Razor is all about. Application platform is the same. It's just view engine that's different.

- 103,639
- 52
- 277
- 404
1)The aspx application architecutre has everything preconfigured to use and its a heavy.
the asp.net razor or asp.net MVC has minimal items preconfigured to use and its much more
efficient to use. you Load items when you need in MVC
2)the aspx has views which not testable. but the MVC the view are testable.
3)The mvc has more inbuilt validations in the basic razor \ mvc tags which you use for development hence can be cleaner than aspx
4)the aspx does not force you to make a structured final product but MVC forces you to follow structure hence makes the final product much cleaner and organized. There are always lot of advantages of structured programming.
and so on..

- 15,908
- 4
- 48
- 41
-
1Firstly, his question wasn't about MVC vs Webforms, but rather Razor vs aspx in WEBFORMS. Secondly, webforms not testable, heavy etc? If you've never seen a badly written MVC website, good for you, but maybe you should do some research on this matter too. The quality of the code depends solely on the programmer himself. – walther Jun 07 '12 at 09:57
-
@Walter Thanks for your comment. below are my views a)The razor works only with MVC hence hence i felt my comparision is valid of comapring MVC vs Webforms b)can we test views in webforms as possibly as in MVC? i dont think so. c)badly written MVC is possible but its more possible by default in aspx since it has no constraints by default to enforce (like no rule land). d)MVC lighter because No ViewState by default. and few more reasons why MVC are referred in the [link](http://stackoverflow.com/questions/5930730/how-to-decide-on-webforms-vs-asp-net-mvc-3-for-new-project) – Ram Jun 07 '12 at 13:05
-
a) wrong. You can use it in WebPages and WebForms as well. http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx#7553469 (see Summary) and you can always utilize this http://razorengine.codeplex.com/ . Well, if you know how it works of course... b) there are no views in webforms and if you separate the logic from presentation layer, sure you can test whatever you want. Many people like to mix it like crazy and then they are all over the place it isn't testable. >>> – walther Jun 07 '12 at 15:13
-
c) no, it's not more/less possible with either of these approaches. Underlaying layer is still asp.net and it's entirely up to the programmer to know the technology he's using. Asp.net is just a tool, it isn't good or bad. I separate logic, presentation, data, etc. in webforms more than many people I've seen using MVC. d) viewstate isn't that much big deal if you can actually use it. Except other things, it can pretty much act as a security layer as well. When using MVC, you need to create additional logic to do the same job. – walther Jun 07 '12 at 15:17
-
Lastly, this is my final comment, neither MVC or Webforms is superior to the other. Both are valid approaches, both are supported by Microsoft and it's entirely on the programmer to decide what he likes and what not. If you feel great about MVC, by all means, use it the best you can. But I don't understand the attitude, that people like to talk this way and treat other approach as inferior, just because they can't really utilize its power and tools. You don't have to use predefined webforms controls... No one is forcing you and that's the thing I love about asp.net and C# in particular. – walther Jun 07 '12 at 15:21
-
@walter Thanks Walther for taking time to help understand. i agree with you. – Ram Jun 11 '12 at 06:47