Setting up a new project

Open Visual Studio 2010 and create a new ASP.NET MVC 2 Web Application:


After the project has been created, add a reference to the MVC.Controls.dll:


Now, we need to add all the js, images and css’s files required (the files are part of the binaries release).

While you can place this folder anywhere you’d like, the default location is as follows:


Final thing we need to do, is add links to the scripts and styles from our views.
Instead of manually adding this links to every view, it simpler to go directly to Site.Master (located in the Shared folder) and in the head tag, add the following:

<!-- MVC.Controls -->
<% =MVC.Controls.MVCControlsScriptManager.Instance.RegisterScriptsAndStyles() %>
<!-- End of MVC.Controls -->

Now we’re finally ready to start coding!

Next post: The Grid Control Overview

Last edited Feb 20, 2011 at 9:29 PM by sternr, version 1


sternr Apr 28, 2011 at 9:02 AM 
When using the Razor view engine, instead of Site.master, you get a file called _Layout.cshtml under the Shared folder which is basically the Razor equivalent of Site.master.

(Note: make sure to use the Html.Raw wrapper when using Razor)

kainhart Apr 22, 2011 at 4:52 AM 
Any chance this can be updated for ASP.NET MVC3. I'm just starting out learning ASP.NET MVC and there appears to be no Site.master file created for a razor based ASP.NET MVC3 project and it's throwing me off.