tags:

views:

319

answers:

2

I have got an app I'm writing and I'm currently considering using MVC to develop it. I have used MVC quite a few years ago under J2EE, so I have some familiarity with the framework, but I want to review how it is implemented under ASP.NET before I go ahead with it. I have done some prototyping using webforms and have written some quite good functionality (mainly as POC during the prototyping) but I can't see that being useable as-is under the MVC framework.

Thus, my question is this: how many people write MVC/webforms hybrid apps, and what are the pitfalls for doing so? I would like to write the app under MVC as there are many common screens that are used in different workflows, so the MVC architecture seems ideal, but there are also quite a few screens that I can quickly develop using some of the webforms tools (e.g. the gridview) and so it would be advantageous for me to be able to do so. I think I am fortunate in that the webforms-style pages are either pretty much standalone (i.e. in a single screen flow of their own) or would feed into the flow screens (for example, I haven't ever used to the gridview to update/insert/delete data, but rather as a search screen which would enable selection of a record which would then progress into an MVC-type flow). Has anyone any thoughts or experience of this sort of thing?

Cheers

MH

+2  A: 

I've just gone through an app that has a WebForms MVC hybrid layout and functionally it works just fine. There are a few issues to watch out for such as having web forms in folders that are also used for routes which can cause MVC routing to fail in odd ways, but otherwise there are no problems I've encountered in mixing Web Forms and MVC.

However, once you get going you will probably find that this sort of setup feels wrong - as you are switching between abstractions. While it might be easier to get some of the Web Forms pages slapped together using some of the high level controls you probably find that you're also cutting corners in other parts of the application. For a brand new application, starting from scratch I would seriously think about building the application with only one type of tool for consistency and easier maintenance through the product life cycle even if at the outset it might seem that one or the other might be easier initially.

Rick Strahl
+1. Interesting. I've read about integrating the two, but not actually done it, so your experiences are useful. The only scenario I can think of it actually being useful is as Mad says you have a lot of grids (particularly master/detail).
RichardOD
+2  A: 

Scott Hanselman has this article that should be useful. It goes over some of the routing scenarios and other intricacies.

Plug-In Hybrids: ASP.NET WebForms and ASP.MVC and ASP.NET Dynamic Data Side By Side

Robert Harvey