Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know Microsoft has said "MVC is not a replacement for webforms". Some developers say webforms is faster to develop than MVC, but I believe this all comes down to comfort level with the technology; so I don't want any answers in this direction.

Given that MVC gives a developer more control over our application, why is webforms not considered obsolete? When should I favor webforms over MVC for new development?

share|improve this question
22  
@Darknight :\ that's highly biased and simply wrong. MVC is not for simple CRUD apps. I'd argue WebForms is for generic CRUD apps (i.e. database -> some shiny grid control). – Raynos Nov 13 '11 at 12:29
5  
@Darknight whatever makes you happy -> if you like WebForms go crazy with it ;) – Raynos Nov 21 '11 at 13:22
7  
@Darknight You obviously have a poor understanding of MVC if this is your opinion... There are some huge sites built with mvc... do some research sir. – Robotsushi Nov 29 '11 at 18:44
7  
IMO, never use webforms when you can use MVC instead. – scottschulthess Jan 15 at 19:23
2  
I'm not one to speak so this is just my opinion. After reading most of the answers I came to conclusion that the answer is just never. MVC is just awesome and the only drawback I found is that I keep seeing ; at my webpage (If you're just beginning with Razor you'll get the joke). – Ken Jan 24 at 14:09
show 5 more comments

22 Answers

up vote 31 down vote accepted

Webforms vs. MVC seems to be a hot topic right now. Everyone I know touts MVC to be the next great thing. From my slight dabblings in it, it seems ok, but no I don't think it will be the end of webforms.

My reasoning, and the reasoning as to why webforms would be chosen over MVC, has more to do with a business perspective rather than what one is better than the other.

Time/money are the greatest reasons why webforms would be chosen over MVC.

If most of your team knows webforms, and you don't have the time to get them up to speed on MVC, the code that will be produced may not be quality. Learning the basics of MVC then jumping in and doing that complex page that you need to do are very different things. The learning curve is high so you need to factor that into your budget.

If you have a large website written all in webforms, you might be more inclined to make any new pages in webforms so that you don't have two very different types of pages in your site.

I'm not saying it's an all or nothing approach here, but it does make your code harder to maintain if there is a split of both, especially if not everyone on the team is familiar with MVC.

My company recently did three test pages with MVC. We sat down and designed them out. One issue we ran into is that most of our screens have the View and Edit functionality on the same page. We ended up needing more than one form on the page. No biggy, expect then we wouldn't use our masterpage. We had to revamp that so that both the webforms pages and MVC pages could use the same masterpage for common look and feel. Now we have an extra layer of nesting.

We needed to create a whole new folder structure for these pages so that it followed the proper MVC separation.

I felt there were too many files for 3 pages, but that is my personal opinion.

In my opinion, you would choose webforms over MVC if you don't have the time/money to invest in updating your site to use MVC. If you do a half arsed approach to this, it won't be any better than the webforms you have now. Worse, you could even be setting this technology up for failure in your company if it's messed up, as upper management might see it as something inferior to what they know.

share|improve this answer
5  
This is a good answer. I gave you +1 because your personal experiences are appreciated. But, this is failure due to a lack of experience/skill-set of the developers which I asked to avoid. I am not convinced that Microsoft would choose not to mark a technology obsolete simply because of a fear of the learning curve for MVC. This may be the case, but I'm not yet convinced. – P.Brian.Mackey Jul 22 '11 at 19:26
1  
@P.Brian.Mackey - I didn't say that forms development is faster than MVC. You asked to leave that argument out of it. Arguing time and money to train your staff is a different argument. MS won't mark webforms obsolete for one big reason: Enterprise clients have spent years developing web clients in webforms and won't look kindly on having to invest time and money to update. – Tyanna Jul 22 '11 at 19:39
13  
@Raynos - If everyone on the team was proficient in MVC, and your company was starting a new project, then the only reason I could see someone choosing webforms is personal choice. – Tyanna Jul 23 '11 at 19:20
4  
Also, if expert client-side developers annoy you, webforms is like expert client-side developer repellent. Definitely go with webforms if you prefer the JavaScript/CSS guy be frightened and intimidated at the prospect of losing a webforms gig. – Erik Reppen Aug 18 '12 at 6:57
1  
I started with Webforms and once I discovered MVC I switched to that. I don't know how anyone could defend webforms. Page lifecycle and one form for the entire page? Are you kidding me? Yahoo sitebuilder was probably the intended customer for it but even they didn't want that junk. – Nick Apr 3 at 21:32
show 3 more comments

I emailed Scott Guthrie, an MVC expert at Microsoft. And probably the most qualified man to answer this question. He was kind enough to reply:

"Different customers look for different programming approaches, and a lot love WebForms and think it is great. Others love MVC and think it is great. That is why we are investing in both. "

So, to me this says that its not a technical issue. Its more of a "soft issue", if you will. One of personal preference. This is in line what several of you have said.

Thanks for all the answers.

share|improve this answer
1  
Scott Guthrie invented the MVC framework for ASP.NET while on a flight back from London to Seattle in 2006/7. Come to think of it, he pretty much invented .NET too (en.wikipedia.org/wiki/Scott_Guthrie). Calling him an "expert" is an enormous understatement ;-) – codegecko Aug 15 '12 at 18:09
11  
That's a nice political answer from Scott Guthrie. If he himself were investing his own Web application you'd see an MVC project and for anything that couldn't be done in MVC, Silverlight would be the fallback. Don't take this as a comment negative towards WebForms, I think WebForms are great for smaller-scoped internal applications that can benefit from 3rd party components such as those created by Telerik. I'm glad Microsoft is moving forward with both technologies. – Sean Chase Sep 23 '12 at 16:47
show 1 more comment

I developed ASP .Net WebForms applications for 3 years, and after one day of doing an MVC tutorial I was sold. MVC is almost ALWAYS the better solution. Why?

  • The page lifecylce is simpler and more efficient
  • There is no such thing as controls besides html controls. You don't need to debug your output to see ASP .Net is generating.
  • ViewModels give you immense power and obviate the need to do manual control binding and it eliminates many errors relating to binding.
  • You can have multiple forms on a page. This was a serious limitation on WebForms.
  • The web is stateless and MVC matches the architecture of the web more closely. Webforms introduces state and the bugs you have with it by introducing the Viewstate. The ViewState is automatic and works in the background, so it doesn't always behave the way you want to.
  • Web applications need to work with ajax these days. It's not acceptable to have full page loads anymore. MVC makes ajax so so much better, easier and more efficient with JQuery.
  • Because you can have multiple forms on a page, and because the architecture is driven by calls to urls, you can do funky things like ajax load a different form, like an edit form into your current page using JQuery. Once you realise what this lets you do you can do amazing things easily.
  • ASP .Net WebForms is not only an abstraction over html, it is an extremely complex one. Sometimes you would get a weird bug and struggle with it for much longer than need be. In many cases you could actually see what it was doing wrong but you are unable to do anything about it. You end up doing weird workarounds.
  • WebForms does not make a good technology for designers. Designers often like doing html directly. In MVC its a view, in WebForms its half a day of work.
  • As the web platform is evolving fast WebForms wont keep up. Its not aware of new tags or features of HTML5, it will still render the same stuff unless you get (often) expensive 3rd party controls or wait for Microsoft to issue an update.
  • Controls in WebForms limit you in so many ways. In MVC you can just grab a JQuery library and integrate it into your templates.

I know some of the issues above have been addressed to some extent as WebForms evolves, but that was my original experience. All in all I would find it extremely hard to find a business case for WebForms unless a project is already using it.

share|improve this answer
show 1 more comment

I am a complete and total convert to ASP.NET MVC and have not looked back, that said I do still have to maintain several very large WebForms apps. Here's my take on it:

WebForms
Use these when you have some serious heavy lifting to do with grids. The grid controls are really very nice when you have a simple dataset that fits nicely in a tabular format and you want to provide a simple way for users to update records. Yes, I know that MVC 4 has a really snazzy Ajax list-type thing that you can use which works great but, in our business we often need to get something running yesterday and good old-fashioned grids work great and users are happy to be able to tab across a grid with glee. For me that's really the best thing about WebForms for me; but, as Ryan pointed out WebForms can be a big time mess because you're playing both sides of the fence from a nifty code-behind file. It can be both a rose and a thorn at the same time to keep all of your controller-type stuff intermixed with your view(s).

MVC
Use this when you really want to roll your own and you have the opportunity to start an application from scratch. Having a clearly defined MVC application is a bit more work to get started with but its benefits in maintainability outweigh the initial setup cost. If you want to do interesting Ajax interactions, prefer to write your model with code, like clean url's and routes, and be able to control the entire flow of your app than this is definitely the way to go. It takes some getting used to at first but I think it's the better option for greenfield apps.

In conclusion, for me, it comes down to grids and !grids. :)

share|improve this answer
show 1 more comment

My experience:

  • Wrote CakePHP projects for one year.
  • Completed a medium sized Webforms project over six months.
  • Worked on a Windows Forms project for three years.

After that experience, I tried writing another app using webforms, and got frustrated after struggling for about a day with how webforms attempts to shield the developer from the reality that they're developing an application which uses html, javascript and css.

I then tried MVC out, and having more direct control over the output (and some experience with the MVC paradigm from CakePHP) I was able to complete that simple app exactly the way I wanted it in about 1/2 a day.

The availability of powerful UI frameworks like jQuery very much eliminates the appeal of giving up direct control of the output in favor of using often bulky pre-built UI components.

share|improve this answer
2  
@JimG - Uhh, anything which involves a person entering records without interesting associations into a database, and having that person or someone else read/print them at some other point can be basically scaffolded using an MVC framework. Granted, that isn't most apps, but it's a heck of a lot more than you can do with Forms. I guess your -1 proves my point. – mootinator Jun 17 '12 at 16:46
1  
But if the requirements amount to "I need an app with two roles, one to record some information, the other to look at it, and I don't really care what it looks like." Then, yes, that's quite doable. – mootinator Jun 18 '12 at 0:19
1  
im sorry, but developing a webforms app to enter data and view data is so simple, that it can be done in a few hours. creating the structure of an MVC app, Controllers, Views and Actions, would take the same amount of time, but will not get you to a finished product. – Dementic Jun 20 '12 at 15:41
2  
@Dementic Usually for a simple MVC app one builds models, then scaffolds controllers and views and/or generates scaffolded controllers/views. Nothing really time-consuming there. – mootinator Jun 20 '12 at 18:32
show 3 more comments

This answer is going to get downvoted into oblivion but, on the whole I see WebForms as being for cargo-cult programmers, while MVC is the technology of choice for more seasoned developers who understand the importance of simplicity & maintainability.

share|improve this answer

I have read all the answers and feels my personal experience would add something to the answers above.

3-4 years back, I developed 2-3 website projects using Webforms. Around that time, MVC wasn't around or i didn't heard of it. The development was naturally(I was coming from Win-forms development with no prior web development experience) fast for me, since i need not to learn HTML in details and web-controls helped a lot (a hell lot, it made life easier).

Now, after all that time, i wasn't working any web project until recently and merely building some windows application using WPF.

Few days back I had an idea for a website and thought of developing it : this time around in MVC (since its talked about everywhere, besides i needed to learn either, so i choose MVC). The project is still in development phase, since i am still learning and building together.

So, the Key differences i find b/w the two are following :-

  • For someone coming from windows development, Web forms will always be favorable. Asp.net learning curve for a windows developer is bit steep

  • For someone coming from web development in some other technology, MVC will be favoured since it mocks the latest of them all.

  • Development is easier and cleaner in MVC if you are equipped with good knowledge of HTML and CSS

  • Deployment is still an issue. In web forms one just needed to do copy and paste. But, this requires some things to be done.

In short, both of them will stay here for a while.

share|improve this answer

I prefer webforms because my background is windows development.

Speed of developmnt is a key issue, and I can easily pass a problem to someone in india to fix overnight with forms, also, if I have a speed issue on a page, a really good book about asp.net speed is handy ( Rick Kiessig is the man ).

webforms is for ex windows people mvc is for web people

but, in the modern world, where Rick has written an awesome book, with servers increasing in speed daily and cheap coders in India, well, webforms has the edge

share|improve this answer

Our reason for not going to MVC a few years ago was it was an immature technology from Microsoft. Over the past few years we are now on a more mature version (4) and MS seems to have worked out where they are going with this. However, we are still reluctant on developing major LOB apps using MVC as the features we want to use in version 4 require a windows 2012 server (re web sockets via IIS8). I reckon in 1 more year we will be more accepting of MVC as hopefully more third party controls will be available, the technology will have settled, and we will have the infrastructure to support it.

share|improve this answer
show 1 more comment

My 2 cents is to always use ASP.NET MVC for new projects if you have the option. In my opinion, webforms is not a good way to develop web apps, period.

I think abstracting away basic REST is bad, the entire postback model is bad, the way html/css is handed with a reliance on the GUI editor is bad, the emphasis on stuff like wizards and GUIs to set stuff up is bad, the URLs are bad.

share|improve this answer
show 2 more comments

I've not seen this consideration put forward amongst the existing 15 answers to this thread yet, but I think it's worth considering.

From my experience Web Forms is more similar to Win Forms and WPF than MVC is. Given this, I think one might consider choosing Web Forms when the team has most experience in that kind of tech, or when the Web Forms project will deliver an interface on to the same data set as an existing (or concurrently developed) Win Forms or WPF project. Doing so allows developers to cross between projects more easily, since application logic may be quite similar between the two.

As other answers have pointed out, development on the MVC framework is more similar to web development in Ruby, PHP, Python etc than its Microsoft counterparts; so naturally the choice of MVC can be influenced by the teams experience in those areas, along with the factors submitted in other answers.

share|improve this answer
show 1 more comment

This decision depends on your preferences, on your requierements or even on your knowledge and experience.

The time for training learning MVC or time to get a delivery. All this things matter to choose one or other aproach.

Is not that one is better than another, simply both aproach or frameworks have pros and cons.

Personaly I favor MVC 3, I recommend you to try an get your own experience, but I need to say that program in MVC is a clean, fun, flexible, extendible, secure and structured way.

Regards,

share|improve this answer

ASP.NET MVC is really an answer to Ruby, and the new, trendy, and (IMO) better way of decoupling the browser(client) from the server as much as possible.

ASP.NET Webforms gives you a lot of control over the client from the server side, with direct access to pretty much everything. Essentially your view and controller are one in the same, which gives you a lot of power, and most times a lot of mess.

ASP.NET MVC separates the view and controller by detaching the tight coupling of a .aspx file and the .aspx.cs file which accompanies them in webforms.

Essentially, the difference is having your much more (typically all) of the processing to display data to the view file, and leaving the business logic and the rest in the controller, keeping them both cleaner by convention, but also with less access to each other than webforms allows.

share|improve this answer
show 2 more comments

This is all about personal choice, assuming we are all proficient with the technology we use. I have been using the WebForms design approach for many years, and I must say that the only downside is that due to it's simplistic approach, many people do not take their time to unearth it's vast capabilities.

I recently used MVC to complete a project, and while I quite like the design approach to application development (which gives you more control, clean urls, SOC, etc), there really isn't much it provides, that WebForms can't. In fact, the emergence of jQuery and it's workings with WebForms (as well as MVC) has made these arguments less of an issue. And when people talk about separation of concerns as an advantage MVC has over MVP, I ask them how much they know about Object Oriented programming and how much they put into use the principle of abstraction and polymorphism.

I am currently comfortable using both technologies and I pick and choose based on the situation. Frankly speaking, it is up to you, but the truth remains that not everyone takes their time to learn in depth what a particular technology is capable of.

share|improve this answer

When faced with a programming problem I often look to the web for answers. Webforms has tons of information/components on doing just about anything. In MVC due to fewer sources online and the layers of abstractions needed to make something work has put a limit in things that I could once do. MVC total kills my productivity as a developer while with Webforms it ain't. So for now I'm sticking to webforms until MVC has matured enough to replace it.

share|improve this answer

I think the gap between these two technologies isn't as wide as it used to be.

  • Web forms can use the routing engine that MVC uses ( or something very similar).
  • The script manager can combine scripts, load from a CDN, and even delay the loading of scripts.

To directly answer your question I think it comes down to preference and/or what the project is. They both take a significantly different approach to development. Personally i've been working on moving towards MVC, but still enjoy working with Webforms. I think the answer to wether you should use MVC or Webforms is for you to decide through experiencing both technologies.

share|improve this answer
1  
Webforms and MVC recommend a radically different web development attitude by default, this is important, few developers deviate from "the default". Both of them can be used to achieve the same thing though. – Raynos Jul 23 '11 at 18:26

In my opinion, they are related enough and have roughly the same capabilities that it should come down to preference.

A great WebForms developer can produce a product equally powerful as a great MVC developer. But the great WebForms developer trying to force himself/herself to adopt MVC is going to come up short. Same goes for a great MVC developer giving WebForms a shot.

They are not completely separate entities, and as long as Microsoft continues supporting both, I believe you will continue see a mixed group of exceptional developers for each.

share|improve this answer

In my optional, why ASP.NET MVC cannot replace webforms, because,

  1. ASP.NET webforms is about 10 years and widely use today, even ASP.NET 2.0,3.5,4.0.
  2. Many commercial UI control library still in the market and it's their main profit. If MS declare the mvc will replace webforms, i think these company get a big problem.
  3. ASP.NET webforms enough to satisfy most web applicatio's requirement, and asp.net 4.0 have improve viewstate size, resulting enhancement on the speed, the cache, and implement some mvc feature RESTful url ,routing for webform etc.
  4. Webform is Event-Driven, many asp.net developer is well-known on them, and on some stage, webforms have better control into a page life-cycle, for example : page_preinit -> page_init ->page_render->page_load->page_loadcomplete .... It's better control our logic in different event.

For me, i work with ASP.NET about 7 years, and asp.net mvc release almost 3 years. But for my work and personal project, i still don't necessary to use asp.net mvc to complete my project.Alternate to say, What asp.net mvc can do, webforms can do.

I have spend much times on ASP.NET MVC 2.0 and complete a CMS system, but i get a final answer to make me stick on webform is - ASP.NET MVC doesn't make my work faster then webforms.

PS: forgive my english, i am speak chinese.

share|improve this answer
3  
The page lifecycle in WebForms doesn't make it better. It makes it more complicated and error prone. – Tjaart Oct 19 '12 at 7:38

Well, web forms have more learning resources available (simply due to the fact that it's older) and thus new programmers that aren't "In the know" will be more likely to find information regarding this older technology as opposed to the newer stuff like MVC.

Senior/experienced programmers are older and will be more proficient in the older technology due to the fact that they've programmed in it longer than they have the newer one.

Unless you can spend the money and effort to get your guys as proficient in MVC as they are in web form applications, your undoubtedly going to try and hold off upgrading to the new platform for as long as possible.

So it presents several logistical problem: Do the benefits of MVC outweigh the it's cost in terms of lesser quality and deployment time? If I have a site written entirely in webforms, would it be worth the effort and money to integrate MVC into it?

As stated by a previous commenter, MVC also prevents you from achieving the same level of interface with the controller as you would be able to with web forms. While I'm all for the "Keep the user from fucking shit up/learning" side of things, it can still be unreasonable troublesome for teams to deploy/implement a program that fanatically sticks to that paradigm for everything they write.

share|improve this answer

I think we are forgetting that MVC is a design pattern and APS.NET MVC is just one MS implemention of it. In true MVC patterns, I should be able to replace the view (presentation) with anything and reuse my controller and model logic.

share|improve this answer
1  
everyone on this thread is referring to ASP.NET MVC, the product by microsoft - not MVC the design pattern, though the product is named after the design pattern because it uses it. – scottschulthess Jan 15 at 19:25

If you have been in the job market recently everyone wants MVC. You will be viewed you as an inferior developer if you don't have this experience. VB developers are considered inferior. C# developers are considered to be superior. In this profession those who have superiority complexes shout the loudest and get the most attention. The only constant is change. Years from now there will be another new buzz word and fad. It is like a dog chasing its tail. If you can't keep up with the changes you will become obsolete.

share|improve this answer
show 1 more comment

MVC requires javascript knowledge and a lot of web coding while webforms treats the site as a form. Webforms is microsoft technology and ms will never abandon it. If you are willing to go with MVC, just do your website with php or ms webpage, it much easier.

share|improve this answer
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.