I have an existing ASP.NET WebForms 3.0 application that works just fine. I upgraded it to ASP.NET 4 and it still works great, but now I want to add some ASP.NET MVC pages to it. I don't want to rewrite the application.
Any suggestions? Can I mix them? How to work it? Any tutorials for me?
Luckily, the answer is yes. Combining ASP.NET Webforms and ASP.NET MVC in one application is possible—in fact, it is quite easy. The reason for this is that the ASP.NET MVC framework has been built on top of ASP.NET.
If you add a plain ASPX page to an ASP.NET MVC project, well, it just works like a charm without any changes to the configuration. If you invoke the ASPX page, the ASPX page is processed with viewstate and postbacks.
Does this mean ASP.NET Web Forms is dead and should no longer be used? Of course not! As long as the . NET Framework ships as part of Windows, ASP.NET Web Forms will be a supported framework.
Asp.Net MVC has Partial Views for code re-usability. Asp.Net Web Form has built-in data controls and best for rapid development with powerful data access. Asp.Net MVC is lightweight, provide full control over markup and support many features that allow fast & agile development.
Take a look at Scott Hanselman's blog article on this very topic:
Integrating ASP.NET MVC 3 into existing upgraded ASP.NET 4 Web Forms applications
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With