views:

826

answers:

6

I'm thinking about trying out MVC later today for a new app we're starting up, but I'm curious if it's an all or nothing thing or if I can still party like it's 2006 with viewstate and other crutches at the same time...

+4  A: 

Yes. MVC is just a different implementation of the IHttpHandler interface so both classic ASP.NET and ASP.NET MVC pages can coexist in the same app.

Joel Cunningham
A: 

If you're mixing MVC with other methodologies you're not really getting the benefit out of it. The point of MVC is to allow you to decrease coupling and increase cohesion, and if only half of your code is doing that, then the other half is inevitably going to restrain your development cycle.

So, I guess while it's possible, I don't think it's worth it. Go all the way or don't go at all.

Adam Bellaire
Surely it's all about using the best tool for the task though? Some parts of the project may be better suited to MVC and some to WebForms...
Rob
If you can cleanly decouple the MVC parts from the non-MVC parts, then yeah, you could try it. But if they are both dealing with the same data structures or presenting parts of the same user interface, then I personally would advise against it.
Adam Bellaire
+5  A: 

Yes you can have your webforms pages and MVC views mixed in a single web application project. This could be useful if you have an application that is already built and you want to migrate your app from webforms to mvc.

You need to make sure that none of your webforms pages go in the 'Views' directory in a standard ASP.NET MVC application though. Pages (or views) in the 'Views' directory can't be requested directly through the url.

If you are starting an application from scratch, there would be very little benefit to mixing the two.

Chris Sutton
A: 

You'll need to make sure your MVC routes don't conflict with your Web Forms pages so that requests for a .aspx page don't get routed to a controller action as a parameter etc.

See this blog post by Phil Haack for details on how to avoid this.

Luke Bennett
link broken. Please Fix.
Scott
A: 

As you've probably noticed with the above answers, yes this is very possible to do.

I've actually had to do this on my current project. I was able to get approval to add MVC to our application, but only in the administration section (to limit the risk of affecting current members coming to our site).

The biggest problem I had was converting my Web Site to a Web Application, but once that was done, things were pretty straight forward adding MVC side-by-side our classic code-behind web pages.

The trick for me was to make my MVC pages look as similar as possible to my code-behind pages so the transition looked as seamless as possible.

Elijah Manor
+1  A: 

I am currently working on a new project. While I would like to go down the MVC route all the way, some of the project requirements don't allow me.

One of those requirements is to have a grouping grid from the client-side. Personally have chosen the Telerik Rad-Grid. While they may be in the process of supporting MVC they are not there as yet.

So this means that I have to have a hybrid solution. for the time being until RadGrid fully supports MVC.
While we are in this transition period I think that there will be may more hybrid projects out there until the support of the Third Party Controls catches up.

Regards

Nathan

Nathan Fisher