Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a single page of ASP.Net MVC to an existing Web Forms app?

I've been poking around this site and I've seen a few post about how to "migrate" to MVC from Web Forms... but as a single developer working on a complex Web Forms app I simply don't have the time to to a full migration. What I want to do is add all new content using MVC, and migrate older content over as I have time (and/or have too). I see a lot of benefits for my environment with MVC.

Another thing to note is that all Web Forms .aspx are living in the root directory at the moment, and I have some old school URL Rewriting setup (like: "/id/123/s/whatever/PageName.aspx" -> "/PageName.aspx?id=123&s=whatever") that might complicate things.

There also is a templating system that uses MasterPages that might pose a challenge. Are those handled differently with MVC?

At this point I haven't added anything MVC related to my application.

So, how do I go about, step by step, adding my first Model, View and Controller to an existing Web Forms app?

Edit:

I also found this article which details most of what I needed to do: http://blogs.imeta.co.uk/MGodfrey/archive/2009/03/31/663.aspx

Unfortunately it's still not working. I think because I have a Web Site and not a Web Application. (In other words my classes are living in the App_Code directory).

like image 478
Ben Lesh Avatar asked Oct 30 '09 20:10

Ben Lesh


1 Answers

Scott Hanselman has some pretty good articles on mixing MVC and webforms. One article that seems similar to what you're looking for is here.

And another article for adding MVC to existing apps with step-by-step instructions is here.

The second article pretty much walks you through CH12 of ASP.NET MVC 1.0 by the guys who wrote ASP.NET MVC. Of course it's from a different book, but the content is the same.

like image 151
Jim Schubert Avatar answered Sep 19 '22 13:09

Jim Schubert