tags:

views:

1158

answers:

5

Please keep in mind that this is new for me and I might have missed something important.

I have an existing website, based on an ASP.NET web application. I am now using ASP.NET MVC for new development, and intend to gradually replace the bulk of the pages with MVC based pages.

I have two issues here:

1) I need to replace the pages gradually, because I cannot convert everything at once. 2) Existing URLs (of physical files) should be preserved if possible.

The way I see it, I have the following options:

1) Create a brand new MVC web application in the root of the web site, and then include existing HTML/ASPX/ASMX/... pages to that. This way, the routes are always relative to the root of the web site.

2) Modify the existing Global.asax, Web.config, Default.aspx (and so on) to switch the MVC handler on for routing, and then publish my MVC application to a subfolder.

What is the easiest way to do that, and am I missing something?

Thanks, Laurent

A: 

Scott Hanselman has a good blog post discussing how to combine MVC with Web Forms and other ASP.NET technologies. http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx

Jason Stangroome
A: 

Jason, I saw Scott's post but it doesn't describe what I am trying to achieve. Scott starts by creating a MVC application and then plugging in ASPX and ASMX files. This is easy, obviously. What I am trying to do is find guidance on converting an existing classic ASP.NET site into MVC.

Anyone else?

Thanks, Laurent

LBugnion
+1  A: 

It really depends on the state of your existing web application. If it's mostly just business logic baked into your code-behinds, then you're probably better off with a re-write. If you've got a really decent code separation of your data object models and business layer from your code behinds, then you're ahead of the game on this transition. Unfortunately, this is a really difficult question to answer succinctly and is fairly subjective based on your current state.

"Classic ASP.Net site" - weird to hear.

Chris Conway
A: 

I think the question was wrongly worded, because this is not what I meant.

What I mean is: How can I integrate MVC-based pages in an existing "classic" ASP.NET site (yeah I know it sounds weird :)). I will eventually replace the whole content (and if it means rewriting some pages, so be it) but I want to already add new content based on MVC.

I found guidance about how to create new MVC apps, and even how to integrate new web forms based content in it, but much less about porting an application to MVC gradually.

I found this link http://blog.eworldui.net/post/2008/05/ASPNET-MVC---Living-in-a-Web-Forms-World.aspx

This is promising, but it sounds like a loooooooot of work.

Specifically, I am looking for steps to add new MVC based content in an existing ASP.NET application, and still keeping the old content to work like before.

LBugnion
You could just run a subsite under MVC.
leppie
I tried that but it doesn't work like I would like. Especially, all the relative references are messed up. Do you have experience and guidance with that?
LBugnion
+3  A: 

Like you, I'm tackling this same problem. A few things I ran into I've posted about here http://stackoverflow.com/users/84825/mouffette and they are mainly related to SETUP. The best thing to do is start a new MVC project and compare the files and structure to your existing ASP.NET application. When in doubt just move over line by line and web.config's and eventually you'll get it ;-)

Once you have the plumbing working you then can focus on MVC and it just works side by side.

These links have also helped:

http://media.wiley.com/assets/1539/15/professionalaspnet35mvc_chapter13.pdf http://aspnetmvcbook.s3.amazonaws.com/aspnetmvc-nerdinner_v1.pdf

and you've already found the best site...stackoverflow.

Mouffette