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:?
MVC has no viewstate? So how can I save data in the current page? This seems a very big disadvantage.
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?
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!
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
来源:https://stackoverflow.com/questions/7674102/advantages-and-disadvantages-of-asp-net-webforms-vs-asp-net-mvc-some-points