Geeks With Blogs
Sam Abraham Software Engineer/Architect: Putting Customers First
In this blog post, we will take a quick look at the new MVC 3 project options as well as the pretty sharp Razor View Engine (not suitable for shaving :) ).
 
Based on a nice Stackoverflow post, it seems that MVC 3/Razor will only be supported in Visual Studio 2010/.Net 4.0. This is great as it will give developers yet another good selling point to argue for upgrading to .Net 4.0.
 
Creating a new ASP.Net MVC 3 project
Prior to ASP.Net MVC 3 Beta, Selecting “New Project” in VS 2010 yielded two templates related to MVC 2: An “Empty ASP.Net MVC 2 Web application” and an “ASP.Net MVC 2 Web Application”. This has been nicely re-factored in the MVC 3 template. To create an MVC 3 project, you would first choose “ASP.Net MVC 3 Web Application”. You would then be taken to a new screen to select how you want the project customized with a detailed description of what each available template yields. My recommendation for those new to MVC is to choose the project that already comes with the models, controllers and views for forms authentication and to inspect the auto-generated the code as it offers a great out-of-the-box example on getting started with MVC.
 
Figure 1 - Selecting an MVC 3 Web Application Project
 
Figure 2 - Selecting MVC 3 template and view engine.
 
Razor is a View Engine
Razor came to life as a result of developers’ need for an easier view markup to work with that can deliver a bigger bang for the keystroke.  Razor markup is extremely lean yet equally powerful as other available view markups such as aspx pages. Razor pages are also known as “ASP.Net Web Pages”, hence the file extension choice of either “.cshtml” for c-sharp projects or “.vbhtml” for VB.Net solutions.  Controllers and Models remain unchanged regardless of the view engine of choice. Therefore, theoretically speaking, you can re-use all your back-end code if you migrate existing pages to leverage the new Razor syntax.
 
Syntax Highlighting and Intellisense
While syntax highlighting and Intellisense are not yet available in Razor Pages, a few blog posts suggested how to at least get syntax highlighting for the HTML markup on a Razor Page by selection Tools->Options->Text Editior->File Extensions then mapping the .cshtml/.vbhtml extensions to the HTML editor.
To get Intellisense for JQuery in a Razor Page, simply add a javascript include tag for the JQuery vsdocs.js file.
 
Figure 3 - Enable HTML tags highlighting in Razor pages
 
 
I look forward to share more about the Razor syntax in a future blog post.
 
--Sam Abraham
Posted on Friday, October 8, 2010 12:06 PM Fladotnet.com , Tech Talk , MVC2 , WebMatrix , ASP .Net MVC 3 , ASP.Net MVC 3 Beta , Razor Pages , ASP.Net Web Pages , MVC 3 | Back to top


Comments on this post: ASP.Net MVC 3 - A look at The Razor View Engine

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Sam Abraham | Powered by: GeeksWithBlogs.net