Advantages and Disadvantages of ASP.NET Webforms Vs ASP.NET MVC, some points [duplicate]

岁酱吖の 提交于 2019-12-04 14:10:33

1) MVC has no viewstate? So how can I save data in the current page? This seems a very big disadvantage.

Why do you want to save things in the page? That's what databases are supposed to do. Save data. In the page you simply use a hidden field allowing you to refetch the data from wherever it was initially stored. And for data that can change you have form input fields, so it will be there.

2) Webform says that provide an extensive event model with lots of controls, Doesnt MVC support controls and events as a normal webform?

No, MVC doesn't support controls and events. It supports models, controllers and views.

Lets suppose I am an expert on both? why would I choose one or the other? So far the only good thing about MVC in my opinion is testability, becase Rapid Application Development in webforms win in so many ways to MVC.

That's a subjective question for which there is no objective answer. The answer I can give you is: it will depend on the context. I agree that RAD wins in WebForms, but what you have to remember is that it is not the development of the application that costs most. It's its support and maintenance. So if your application is written rapidly you will ship it quickly indeed but with the time if you don't properly architect it with extensibility in mind this quick application development turns slowly into a nightmare, until the day comes where you simply have to rewrite it because it costs you so much to continue to support it.

Now talking about the RazonEngine, it seems like going back to the old ASP, you cant use server side controls? how is this an advantage for me?

You have total control of the markup, your pages are no longer polluted with useless ViewStates, and at last your markup validates. If you want to reuse some view portions in ASP.NET MVC you could use partial views.

Here's what I can give you as an advice. As you are already an expert in WebForms, that will be a great advantage for you when learning ASP.NET MVC. So learn it and by learning it you will probably start to see by yourself the different advantages and be able to answer yourself the question which one of the two suits you better.

ASP.NET MVC applications hand you back control over the way your application works and it conforms to the 'native' model of HTTP/HTML.

WebForms is an abstraction of web application programming; envisaged to ease the transition for the Visual Basic programmers who were the primary target for .NET when it was launched. The trouble is, it's a 'leaky abstraction'. It uses 'tricks' under the cover to make it appear to operate in a way that is simple for those used to VB's event-based model, such as viewstate and postbacks. The trouble with this (and all those 'leaky abstractions') is that while the basic stuff is easy, once you try to do something that doesn't fit within the abstraction, it gets dramatically more complicated.

If your applications are trivial and the WebForms abstraction consistently works for you, feel free to stick with it. Microsoft have been considerate enough to continue to support it.

But if your applications are at all sophisticated or complex (as more and more are these days), I'd suggest looking at MVC with an open mind.

As a test, take a web developer from a non-Microsoft background and let them loose on both webforms and MVC and see which they're more productive with.

ViewState is a curse, a crutch for people who don't understand that HTTP is a stateless protocol, and try to hammer in a hacky solution for persisting state across requests, leading to a massive fail.

  • Concurrency between multiple clients goes out the window.
  • It is stored as a massive chunk of data in a hidden field leading to increased page load sizes.
  • It is wholly dependent on POST methods, so it breaks navigation in HTML.

Simply put, it is not user friendly at all.

And the markup on those controls are horrible too.


Regarding UserControls: you can use Partials to emulate some of the functionality of Controls.

Events: you model Events through Actions in controllers.


Flame War commence!

Artem Koshelev

Rapid Application Development in webforms win in so many ways to MVC

Yes. Use WebForms if you need RAD, use MVC if you rely more on JavaScript, CSS and HTML.

And use search: https://stackoverflow.com/search?q=webforms+vs+mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!