Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using MVC for new parts of a Webforms project

I really like the MVC "way" and have actually enjoyed learning ASP.NET MVC (I never liked ASP.NET Webforms but I didn't know why until now). The problem is I'm about to inherit a bunch of Webforms code and wondered if I'll be able to add new things to the codebase with MVC instead off using Webforms. I suppose it depends a lot on how authentication is set up and if the code is set up in a way that I can include some library or something and just use those function or if I'll have to recreate them or gasp duplicate them somewhere else. What should I worry about? Should I just stop messing with MVC and get working on Webforms or can I make it work together so that if I need to modify something from the Webforms codebase I can just remake it the MVC way as I move along?

like image 489
tooshel Avatar asked May 08 '09 18:05

tooshel


People also ask

Can you mix MVC and Web Forms?

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.

How do I add a Web API to an existing Web Forms project?

Create the Model and ControllerIn Solution Explorer, right-click the project. Select Add New Item. Under Installed Templates, expand Visual C# and select Web. Then, from the list of templates, select Web API Controller Class.

Is ASP.NET Web Forms dead?

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.

Should I use MVC or Web Forms?

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. Hence it is best for developing an interactive web application with the latest web standards.


2 Answers

I would recommend attempting to only add new stuff using MVC and convert over the legacy webforms code as you can.

This is a pretty decent post of putting them both together in the same project: http://www.chadmyers.com/Blog/archive/2007/11/30/asp.net-webforms-and-mvc-in-the-same-project.aspx

like image 169
j0tt Avatar answered Oct 10 '22 12:10

j0tt


Scott Hanselman has a post that talks just a little about it in his blog. If you want to start going down the MVC route then go for it. I think it probably depends on how big the ASP.NET Webforms app is.

like image 22
sgwill Avatar answered Oct 10 '22 10:10

sgwill