Hybrid WebForms / ASP.NET MVC

Possible duplicate:
ASP.NET MVC with web forms in the same web application?

I am new to .NET applications, I have a web form application that I am working on, and I'm going to start developing new pages, I am trying to create new pages using ASP.NET MVC, but I cannot make the pages fall into controllers. At first I added that the library links added routes to global.asax, but are not sure what is still missing, can someone help me?

THX

+5
source share
4 answers

Reading between the lines I'm collecting, are you trying to add add MVC pages to your existing ASP.NET Webforms web application?

If so, you will probably need a specific MVC configuration. Settings The easiest way is to create a new MVC web application and then combine the configuration settings.

Also, if you are doing a hybrid project, I would recommend giving Scott Hanselmann a read on the topic.

+6
source

The following is a more detailed description of adding MVC to a WebForms application at the following links:

You can also add ProjectTypeGuid to the project file using a text editor ({603c0e0b-db56-11dc-be95-000d561079b0} is used to indicate Visual Studio to use MVC extensions.)

<ProjectTypeGuids>{603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> 

The above links also do not fully cover the system.webserver web.config area that needs to be configured.

+2
source
Scott Hanselman has released a "completely unsupported" Nuget package that adds MVC 3 features to an existing Web Forms project. It also works on my PC (ha ha) and I used it in several projects.

http://nuget.org/List/Packages/AddMvc3ToWebForms

He reported this here:

http://www.hanselman.com/blog/CreatingANuGetPackageIn7EasyStepsPlusUsingNuGetToIntegrateASPNETMVC3IntoExistingWebFormsApplications.aspx

One newb tip: this package will configure your MVC routes in / App_Start / RegisterMvc3Routes.cs

0
source

I have spent a lot of time over the past few months on this. Here are my observations.

Good / Easy - Getting Webforms to be Webforms in MVC Controllers - It was great to just get on a new MVC3 project and drop Webforms pages. - I managed to move the <pages><controls></controls></pages> section to the <pages><controls></controls></pages> directory in the new web.config there

Dirty / difficult

  • Regarding GUID

    • Please note that the GUID must be added at the beginning of the line for some reason ... every time I tried it failed. Until I came across a message that insisted that it would be up to others.
    • Also I don’t know what the difference is, but another GUID works for me ... {E53F8FEA-EAE0-44A6-8774-FFD645390401}
  • getting landing page Webforms caused ALL kinds of crashes.

  • Getting jQuery intellisense for playback using T4MVC

this is what i did to solve this problem

 @if (System.Diagnostics.Debugger.IsAttached) { <script src="../../Scripts/Mvc3/jquery-1.7-vsdoc.js" type="text/javascript"></script> @* 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 web forms. The output of magic strings for static content ( .js , .css , images specifying patterns) is outstanding.
0
source

All Articles