Pages

Tuesday, June 19, 2012

Adding ASP.Net MVC 4 to Web Forms Project


This is probably not what you think. But, since I don't know what you think and that is irrelevant at this point, we can get down to business.

I've just added MVC 4 to an existing ASP.Net Web Forms project. There were a few quirks, especially with all the advice out there in regards to versions of MVC. So, here are some notes I wrote down during the process that can come in handy when performing the same exercise again.

Adding MVC 4

A great start is this article here. However, this relates to older version of MVC so some adjustments are necessary. The section that relates to adding items to the web.config, in particular. Basically, all the 3.5.0.0 versions need to be replaced with 4.0.0.0. The modified contents are here.

Adding Razor

If you are going to add new Views using Razor view engine, a Razor section needs to be added to web.config. In appSettings add this. Add the following code to appropriate sections (declaration in configSections add the Razor section itself) from here.
In Views directory there needs to be web.config. Check the contents here.

2 comments:

Jeremy Schneider said...

You don't know what I think! That was very helpful!

Jeremy Schneider said...

You don't know what I think! That was very helpful!