For those of us who can't always afford to buy the ridiculously expensive VS Pro/Team 2008 - shouldn't Microsoft be giving those out for FREE. After all we are only promoting windows, without us developers the Windows operating system will be more or less like TinyOS. Anyway, lets leave that for another day.
I like using express simply because its lightweight and I don't really use all the features of the Pro versions anyway, I only wish I could "attach to process" then the express editions would be 100% ideal for me. Any who, the express editions do not support MVC - actually they do, they just don't have a template for it. Here is how you can create one, however, if you don't care to learn you can just download the template from the end of this post.
1. Make sure you have .Net Framework 3.0 installed
2. Download and install the ASP.NET 3.5 Extensions
My first step was to create the folder structure to closely resemble the screenshots from the ScottGu the guru himself and then I added all the necessary files with a few code changes.
global.asax
We are going to use this asax file to setup routes when the application starts. If you don't know anything about the MVC framework, what routes, controllers, models, views, etc. are then you might want to read this series on ScottGu's blog.
RouteTable.Routes.Add(new Route
{
Url = "[controller]/[action]/[id]",
Defaults = new { action = "Index", id = (string)null },
RouteHandler = typeof(MvcRouteHandler)
});
RouteTable.Routes.Add(new Route
{
Url = "default.aspx",
Defaults = new { controller = "Home", action = "Index", id = (string)null },
RouteHandler = typeof(MvcRouteHandler)
});
The first set of route sets up the default route, which simply states that the url format that we are going to be using will be formatted like /Controller/Action/Id. So if we want to list all products with id of 5 a sample url will look like: http://www.linkhere.com/product/list/5 where "product" will be our product controller "ProductController", list is our controller action "List()" and 5 is our id "List(string id)". In the route above the Id is nullable, so http://www.linkhere.com/product/list should work just fine.
The second route is what I call a rerouting route, it routes all request to "default.aspx" or "/" back to the home controller "HomeController" and executing the "Index" action. Therefore, all calls to http://www.linkhere.com/default.aspx or http://www.linkhere.com/ will be rerouted to http://www.linkhere.com/home/index - IIS quick fix.
NOTE: You will have to configure IIS for wildcards or add a new ".mvc" mapping to the aspnet_isapi dll.
web.config
I made slight configuration changes to the web.config file which were really simple. I replace all of the 3.5 reference to use the 3.6 references. FYI. When you install the ASP.NET 3.5 extensions it dumps all the files into a weird directory "C:\Program Files\Reference Assemblies", just in case you are trying to locate them. I wonder why they did that? You can copy then in the GAC if you want to, since they are different versions you should be fine, however, the public key token I believe is the same.
HomeController.cs
[ControllerAction]
public void Index()
{
// renders the index.aspx page RenderView("Index");
}
This is just a sample controller which indicates that MVC is good to go. It renders the "Index" view which equates to index.aspx.

Download Template