ASP.NET MVC alongside Web Forms in the same web app?

Mvc is build on top of asp.net as is webforms, so yes it's easy. Done it couple of times for conversion purposes.

Up vote 1 down vote favorite 1 share g+ share fb share tw.

Has anyone successfully deployed ASP. NET MVC alongside Web Forms in the same application in a production environment? Were there any conflicts or gotchas you faced while doing so?

Is it really as easy as shown here in practice? What about if you run a MVC using the Razor view engine alongside Web Forms? Asp.net asp.

Net-mvc-3 link|improve this question edited Sep 2 '11 at 20:45 asked Sep 2 '11 at 20:22T. Webster925412 79% accept rate.

Mvc is build on top of asp.net as is webforms, so yes it's easy. Done it couple of times for conversion purposes Maybe this url's could help you: hanselman.com/blog/IntegratingASPNETMVC3... and hanselman.com/blog/PlugInHybridsASPNETWe....

– T. Webster Sep 2 '11 at 20:45 1 Yes I have. Used these two while converting a webforms application to mvc 3.

You have to do some manual stuff though compared to a newly created standard mvc3 application. – AndrewF Sep 2 '11 at 20:54.

Has anyone successfully deployed ASP. NET MVC alongside Web Forms in the same application in a production environment? I never mixed ASP.

NET MVC and classic WebForms in the same application. I make them run in separate applications and communicate between them with standard HTTP techniques (query string parameters, form posts, cookies, ...). Is it really as easy as shown here in practice?

Yes, it is as easy as that.

It seems like managing communication between separate apps using HTTP is more work than making a call to a class in the same assembly. – T. Webster Sep 2 '11 at 20:43 3 @T.

Webster, I didn't say that it is easier. It is cleaner. Polluting a new ASP.

NET MVC application inside some existing WebForms application is always a bad idea. You will be tempted to do things that you should never do in an ASP. NET MVC application.

You will definitely end up with ugly code that will need rewriting later. Personally I prefer to do tings in a clean fashion when migrating an application, even if it might be a little harder indeed, but to know that at the end I will be happy with the result. – Darin Dimitrov Sep 2 '11 at 20:44.

Check out scott hanselmans AddMvc3ToWebForms nuget package. I am using it and its working pretty great. I am using it to gradually convert my web forms app to mvc.

Nice, but before I can mark this as an answer I'll have to try it for myself. – T. Webster Sep 2 '11 at 20:32.

One gotcha is don't put your WebForms inside the Views folder. I haven't get figured how to make MVC leave those paths alone. None of the ignore routing instructions seems to work in this case and the WebForms throw 404s.

Other than that WebForms works perfectly fine alongside MVC since MVC2.

I've spent a lot of time over the past few months on this. Here are my observations. The good/easy - Getting Webforms to call into MVC controllers - It was remarkably easy to stand up a new MVC3 project and drop Webforms pages into it.

- I was able to move my section into the /pages directory in a new web. Config there The dirty/difficult Regarding the GUID Please note that the GUID has to be added at the front of the line for some reason... everytime I tried it failed. Until I stumbled on a post that insisted it be the before the others.

Also I don't know what the difference is but I have a different GUID working... {E53F8FEA-EAE0-44A6-8774-FFD645390401} getting the landing page to be Webforms caused ALL kinds of snags. Getting jQuery intellisense to play nicely with T4MVC this is what I did to address that @if (System.Diagnostics.Debugger. IsAttached) { @* intellisense!

*@ @Html. RelativeJavascript(Links.Scripts. Mvc3.

Jquery_1_7_js) @Html. RelativeJavascript(Links.Scripts. Mvc3.

Jquery_unobtrusive_ajax_js) } else { @Html. RelativeJavascript(Links.Scripts. Mvc3.

Jquery_1_7_min_js) @Html. RelativeJavascript(Links.Scripts. Mvc3.

Jquery_unobtrusive_ajax_min_js) } Recommendations: Use T4MVC in ALL cases even if you are pure webforms. The elimination of magic strings for static content (.js,. Css, images, specifying templates) is outstanding.

And if you have any part of your build process compiling views then you get compile-time safety on any of those links.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions