Saturday, March 28, 2009

Hybrid ASP.NET MVC and WebForms app

I'm in the process of adding ASP.NET MVC to an existing ASP.NET WebForms app in Visual Studio 2008. One of the neat features of an ASP.NET MVC app is that when you right click on the Controllers folder in the Solution Explorer the "Add" menu item has a "Controller..." menu item on it and right clicking on the Views folder causes the "Add" menu item to have a "View..." sub-menu item on it.

It took me forever to work out how to get my WebForms app to also show those menu items. It turns out that you have to edit the .csproj file for the WebForms app and find the section that reads:


The to that add the following GUID:


Such that it now reads as follows:



  1. How does it even work to have MVC and Web Forms in a single application? Does it go to the MVC router first and fall back to the web forms, or the other way around? Are there any major issues with writing a hybrid application?

  2. In the MVC route mapper you can elect to ignore *.aspx pages so it will got straight to those pages. I believe that it checks the route first. I haven't come across any issues yet but if I do I'll blog them.

  3. Thanks for the info! I'm glad to hear that this sort of thing is supported by default.

  4. For MVC3 use {E53F8FEA-EAE0-44A6-8774-FFD645390401};