3

Possible Duplicate:
Biggest advantage to using ASP.Net MVC vs web forms

I was reading this document

http://msdn.microsoft.com/en-us/library/dd381412(VS.98).aspx

Specifically the advantages and disadvantages:

Advantages of an MVC-Based Web Application

The ASP.NET MVC framework offers the following advantages:

It makes it easier to manage complexity by dividing an application into the model, the view, and the controller.

It does not use view state or server-based forms. This makes the MVC framework ideal for developers who want full control over the behavior of an application.

It uses a Front Controller pattern that processes Web application requests through a single controller. This enables you to design an application that supports a rich routing infrastructure. For more information, see Front Controller.

It provides better support for test-driven development (TDD).

It works well for Web applications that are supported by large teams of developers and for Web designers who need a high degree of control over the application behavior.

Advantages of a Web Forms-Based Web Application

The Web Forms-based framework offers the following advantages:

It supports an event model that preserves state over HTTP, which benefits line-of-business Web application development. The Web Forms-based application provides dozens of events that are supported in hundreds of server controls.

It uses a Page Controller pattern that adds functionality to individual pages. For more information, see Page Controller.

It uses view state on server-based forms, which can make managing state information easier.

It works well for small teams of Web developers and designers who want to take advantage of the large number of components available for rapid application development.

In general, it is less complex for application development, because the components (the Page class, controls, and so on) are tightly integrated and usually require less code than the MVC model.


Because I am a newbie on MVC but not on webforms, I have the following questions regarding this advantages and disadvantages:?

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

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

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.(Just my opinion)

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?

Community
  • 1
  • 1
Luis Valencia
  • 32,619
  • 93
  • 286
  • 506
  • 1
    @Will you are very wrong in closing, its not an exact duplicate, if you take the time to read the question, there are very specific questions in the bottom. Please reopen it now. – Luis Valencia Oct 06 '11 at 13:32
  • 1
    You're right, its not an exact duplicate; its not constructive. This kind of question is no longer acceptable here. Rather than just closing it outright, I've closed it as a duplicate to one of the many other questions that go into the advantages and disadvantages of MVC vs. vanilla ASP.NET. If you have any further questions on why this is, please go to [meta]. I would suggest searching out relevant questions before asking anything. –  Oct 06 '11 at 13:37
  • shame on the vote down with no comment, shame on you – Luis Valencia Oct 07 '11 at 07:41
  • 2
    Don't take it too personally. Lots of people are very protective of SO. They are too quick to assume that someone is being bossy or rude when it could well be the difficulties of writing in languages other than your native one. Or, they may also remember the many questions about the same subject. I know that I've provided a well-upvoted answer for one over a year ago... –  Oct 07 '11 at 13:04
  • @LuisEValencia if you remove your question, I believe you will get rid of the negative votes too. Perhaps that was an idea? Just trying to help. – BerggreenDK May 20 '12 at 19:41
  • Btw. from a website/SEO point of view, MVC gives you much more control of the HTML code rendered + the URL's are much more easy to make SEO friendly without adding extra URL remapping functionality. – BerggreenDK May 20 '12 at 19:43

4 Answers4

10

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.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • everybody that has used asp.net webforms use viewstate, in fact you use viewstate without even knowing it because viewstate is enabled by default in all server controls. – Luis Valencia Oct 06 '11 at 12:24
  • regarding the last answer, does it make the applications faster? – Luis Valencia Oct 06 '11 at 12:25
  • 1
    @Luis Search, again http://stackoverflow.com/questions/221944/is-there-a-performance-difference-between-asp-net-mvc-and-web-forms – Artem Koshelev Oct 06 '11 at 12:27
  • 2
    @Luis I turn off ViewStates and PostBacks in every page. :) – Daryl Teo Oct 06 '11 at 13:26
  • 1
    thank you, as opposed to some moderators here, you really answered a good NOT DUPLICATE question and the entire discussion is very constructive and helpful. People like you is the real people that makes this community to grow. – Luis Valencia Oct 06 '11 at 14:05
5

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.

Steve Morgan
  • 12,978
  • 2
  • 40
  • 49
4

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!

Daryl Teo
  • 5,394
  • 1
  • 31
  • 37
  • this is a very helpful answer +1. what do you think about moderators closing very helpful questions and answers?? -1 for that behavior. – Luis Valencia Oct 06 '11 at 14:08
  • 1
    @Luis: I'm not the moderator who closed it. Sorry – Daryl Teo Oct 06 '11 at 22:11
  • can you please explain me the last part of you answer: It is wholly dependent on POST methods, so it breaks navigation in HTML. I dont really understand it. @Daryl Teo – Luis Valencia Oct 07 '11 at 07:47
  • 1
    If you have a postback action that brings you to a particular state, it is impossible to return to that state from a new session because you require the post information as well. – Daryl Teo Oct 07 '11 at 13:00
1

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

Community
  • 1
  • 1
Artem Koshelev
  • 10,548
  • 4
  • 36
  • 68