Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include MVC 3 views in a Web Forms application

I am developing one new area of a fairly large web application using MVC3 and Razor, where the rest of the application is ASP.NET 4 Web Forms based. Can I include my MVC components in this application, and what do I have to do to achieve this?

like image 796
ProfK Avatar asked Mar 12 '26 14:03

ProfK


2 Answers

Our experience has been that WebForms and MVC work well side-by-side in the same application, but not mixed. In other words, each page can either be WebForms or MVC, but it can't very easily include elements of both. The two main work-arounds I've found are:

  • Make all your MVC elements heavily AJAXified, so that they can be loaded dynamically via AJAX after the page loads.
  • Have two versions of your master pages, and anything else "common" to your web application, to make the MVC portions of your application have the same look and feel as the WebForms portions.

We use the latter approach.

like image 174
StriplingWarrior Avatar answered Mar 14 '26 04:03

StriplingWarrior


http://www.packtpub.com/article/mixing-asp.net-webforms-and-asp.net-mvc

That should get you on the right road. If it was me personally though, i'd add a new project to your solution that is MVC, you can then just configure a Virtual Directory in IIS /MVCApp

like image 41
LiamB Avatar answered Mar 14 '26 04:03

LiamB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!