I think Microsoft must have a reason for enhancing ASP.Net with RAZOR syntax.
On the Create New Website Project dialog of visual studio, there is another o
Well, You have two options:
Use WebForms: use out-of-the box, ready to use server-side controls(mixed markup and business codes) and use master pages and skins, but face some complexity involved of these conveniences! :)
Use MVC: or use separated design model which gives you a more organized codebase. you can first make a design prototype, or first making a business codes, then building the other aspect, quite easy. even you can give the designer more control on his work, giving him/her the ability to do everything he/she wants. -> this one is my preferred choice because it gives me more control on my code, makes my code more concise and clean.
If you selected the MVC pattern, then you are faced with another options... View Engines
You can also write simple asp.net web pages just with razor(C# or VB) syntax. (just like php)
In the MVC pattern, M is the Model, C is the Controller, and V is the View. So, quite naturally, in the ASP.NET MVC model, there is the concept of a View Engine. 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. Razor handles the View part of MVC (If you choose to use it instead of the WebForms one). It has nothing to do with M or C.
Personally, I would definitely go for the Razor View Engine if you choose the ASP.NET MVC pattern, or use plain WebForms without MVC, as Razor has been designed to be less verbose, more simple to use than the Webforms one. It's also simply more recent so it tries to be ... simply better :-)
As a side note, the Razor Parser can also be used outside of ASP.NET MVC. It's implemented in an assembly that does not rely on MVC nor Web assemblies at all. See here for more on this: http://www.west-wind.com/weblog/posts/2010/Dec/27/Hosting-the-Razor-Engine-for-Templating-in-NonWeb-Applications
To get out of all the confusion by webform, MVC, Razor, WebPages and lot more to come from microsoft, I prefer html-->javascript-->webapi.
This is a great question. First, lets characterize Razor.
Razor is an engine that parses server-side code an emits Html, just like ASP.NET Web Forms only with different and arguably more streamlined and terse syntax.
Razor v. Web Forms Sidebar: In ASP.NET Web Forms you have to identify when you wanted to start writing server code with '<%' and then when you were done writing server code you needed to identify that with '%>'. I love ASP.NET Web Forms, but that's clunky. With Razor you identify when you want to start writing server code with '@' and then the next time you start writing a server tag (starting with '<') it "figures out" that you're done with server code. It's a more concise way to write html intermingled with some server code.
ASP.NET Web Pages is a framework for creating simple Web Applications. 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.
Ultimately the goal is to provide choice based on the sophistication of the application that is being built. Understanding each with assist you in making the correct choice for your application.
Additional Links:
There are not code-behinds by default, but you can easily make your razor file inherits from your custom class:
@inherits Index
and then
public class Index : WebViewPage { }
(More information here: http://www.compiledthoughts.com/2011/01/aspnet-mvc3-creating-razor-view-engine.html)
This is more like an old-fashioned way of doing web, more asp3-like. The difference with mvc is that mvc provides a huge framework that supports real world applications (using routing, controller and actions, and not just "code there in the markup").
I think it exists for making things that are really simple, but I don't actually know...
Finally, I would always chose asp.net mvc with razor.
Hope it helps