views:

144

answers:

7

Possible Duplicate:
What’s your choice for your next ASP.NET project: WebForms or MVC?

Can you list some reasons that would make you use ASP.NET webforms for a new project, instead of MVC? I've heard a lot about the opposite, but not things that are done easier or better with webforms. I'm not talking about developer preferences here, but rather technology features and how they map to project features.

+2  A: 

Personally, i find MVC very good for admin-pages. because they usually have a load of tables, and are made for data input and editing. MVC is 'made' for those things, so it's going very fast making those pages.

webforms I use for more complex things, like the User-end of the site. the site i make shows courses people can take. the registering for a course is a 5 step procedure, which in MVC, I have no real idea how to do it. I'm sure it can be done in MVC but I think it's better/faster in webforms.

however in the end I do like MVC more. It feels so much cleaner to work with.

Stefanvds
+7  A: 

The only argument for WebForms is the need to design highly complex (read cluttered) interfaces with a whole lot of interconnected elements which in all or in part should react to changes in other elements.

A typical example would be some enterprise application (from SAP or smaller vendors). They usually have interfaces bordering madness. You'd have a hard time trying to synchronize the controls manually with JavaScript if you were on MVC. With WebForms it's by far easier.

Whether it is a good idea to build such interfaces is another matter entirely.


In WebForms element events trigger a page postback. They go to the same url and are processed in a unified manner. This is what makes the architecture very scalable.

With MVC to accomplish this you would have to set up a bunch of service urls to handle posts from different controls, then process those posts and update view models accordingly. This all involves a lot of trickery and juggling. Not that it is not doable - it is, but not on a big scale. This approach would not be scalable. Sooner or later you will arrive at the understanding you'd need to build your own framework in the direction of stateful object-oriented HTML/HTTP abstraction like WebForms.

A while ago I wrote a comparison of the two:

Migration from ASP.NET WebForms to ASP.NET MVC

Some argued it turned out to be WebForms-biased though I'd tried to keep it neutral not MVC-biased. Could be exactly what you're looking for.

Developer Art
+1 the only answer so far that actually answers the actual question
PHeiberg
I dont know if that is actually true. What you imply is posting back and "syncronizing controls" there. In my experience, that's definitely not acceptable for complicated web interfaces, so some form of JS is almost always used. This is entirely compatible, in fact favourable in the MVC environment
Jonathan
In short, the biggest advantage is the ability to do a postback when you need to. Makes sense, thanks. @Jonathan Why would it be favourable to use JS in MVC as opposed to webforms?
Slavo
@Slavo - most people use the default scriptmanager that pretty much is standard fare in webforms. That brings a huge overhead with the MS ajax librarys being included. You can avoid this, but with MVC that's not the case, and by dropping in the jquery item by item you are bringing into the client side only what you need.
Jonathan
A: 

It depends!

The difference between WebForms and MVC is if you can TDD and control the complete markup.

Timur Zanagar
Not quite of an answer. What does it depend on?
Slavo
It depends on what type of project you have and how the development team is working.
Timur Zanagar
+2  A: 

The only time i would consider going with Web Forms in a new project is if there was a component created for Web Forms that solved a specific problem that would be much harder to solve using MVC.

PHeiberg
+1  A: 

I can no longer see any advantage of Webforms over MVC, apart from some upskilling effort which should not be prohibitive.

[Originally I believe MVC wasn't compatible with webcontrols, so wishing to use Dundas chart control for example wasn't possible. That would have been a good argument for using webforms depending upon your requirements. But I believe this is no longer the case, and anyhow, you can include webforms in your MVC project as a worst case.]

Jonathan
+3  A: 

A few things that could push me (back) towards WebForms:

  • I need to produce something that can be taken over by someone who isn't primarily a web application developer (say a WinForms programmer), and the app could substantially be maintained through Visual Studio's Forms Designer. The IDE support makes the development model closer to that of WinForms.
  • An app that needs to look Ajax-y but will be maintained by someone who won't learn JavaScript. I think things like the UpdatePanel (while horrible in so many ways) are actually pretty good for that scenario.
  • Possibly for some kind of demoware, again because of the IDE and ASP.NET AJAX. Fairly quick to knock up some reasonably smart screens without too much thinking.
  • I need a powerful CMS and need to stay within .NET. At this point it looks like there's better choice in WebForms than in MVC (though hopefully that's changing).
  • I'm working with a team who are already familiar with it and aren't going to learn MVC.

Of those, probably the CMS is the requirement I could think of right now that would actually make me use WebForms.

David
Thanks. For the first three points, I guess LightSwitch would be the way to do for you :)
Slavo
+3  A: 

If you only know webforms MVC comes with a learning curve so you will need to spend quite some time training (or risk making serious security or performance errors)

You need a tiny little app NOW It probably is quicker to build a throw away mock application in webforms if you go for the anti-pattern. E.g. SqlDataSource, Logic in your code behinds etc.

Rich controls GridView is an excellent control, having sorting etc all built in for you with little code needed as long as your custom requirements are small.

Lack of web development experience Web forms is just easier. It takes more concerns off your plate. Much better for a newbie as its tough to go wrong.

Having said that, if you know what you are doing or have the time to learn and you want to build a long lasting site, MVC is soooo good. And more fun too.

I'll add that there is nothing really wrong with web forms. It's perfectly possible to build high performance app with it. It's just times have changed since it first came out and MVC has addressed those changes well.

BritishDeveloper