Why webforms over mvc
This is not duplicate question and i have gone through almost all similar question but did not get clear description more in relation with real life example. I do appreciate and expect the explanation of each and every question mentioned below with real life example please don't mark it as duplicate. I know that you can not replace Asp. More importantly, it gives Controller main functions:. It makes testing very simple as Controller operates pure View Model classes, opposed to WebForms which operates events and Form.
And View Model is a class that encapsulates data required by View. It may be shared by Domain Model in simple cases. Why two classes? Here are similar code snippets of ASP. In both cases I assume that IDomainModel is injected. To test WebForms events we need to make a lot of changes and assumptions: we need to make the methods public, we need to initialize Form and its controls.
It results in heavy hard-read tests which are impossible for 3 TDD. I think this statement is a little bit exaggeration. As for HtmlHelpers, DisplayTemplates and EditorTemplates, though the team made major improvements over 6 versions of the framework, it's still sometimes annoying to transform additionalViewData into html attributes. For example, to pass some html attributes to an input you can't use Html.
EditorFor , you'll have to use Html. In the same time in ASP. NET you can specify any attributes on any elements and they will just render.
I think this statement is about testing of Controller vs Code-Behind. I covered this in 1. They are rendered as elements, nothing similar to ViewState. For example, in my View I initialize ViewBag. Title - My ASP. As to TempData, Session and Application, they are stored on server side. It's not rendered to page at all. Here is how we integrate JQuery into WebForms:. It was originally designed for Scaffold Templates based development, and it is best with it.
JQuery is good for ajax requests and for some minor logic in ASP. Hello, Unit Testing! NET is designed with Postbacks in mind and they dictate you the basic application model. NET to make an application more dynamic and there is still some place for JQuery. I am developing applications in both frameworks i. Webforms and MVC, will be explaining things based on my experience. Discipline is the most important thing that needs to be followed with any Architecture you are working on.
There are multiple helper classes which hooks and does help in late bindings, you can mock controller using various plugins. Easy to develop Helper classes. And it matters when we are going with Web form architecture. No ViewState and PostBack events: Viewstate puts extra load on page and in web forms when you see source of a page having lots of controls, grid etc, you will see huge viewstate.
If there is no viewstate life is just simple. ViewData is at client side whereas others are at server side. There are lot of Predefined JQueries that are already introduced in templates. Other than above points some additional points Bundling Refreshed and modernized default project templates Better support of Mobile applications Fast development Code reusability Least coupling within Layers Good support to Ajax.
Difference between ASP. I'd add to the top answers which are generally correct than MVC and Web Pages are both open source, so you have an easy access to the source code, bug database and can even PR bug fixes or features back which we have taken in abundance. At the end of the day it's a personal choice, and also depends on the experience you and your team has and if you have legacy code you want to reuse.
If you have existing Web Forms-based applications, these continue to work exactly as they always have. Before you decide to use the MVC framework or the Web Forms model for a specific Web site, weigh the advantages of each approach.
NET mark up code are used in a Single Page that's why code become very complex. Tightly Coupled -Aspx page and cs page code behind file are tightly coupled. Unwanted Html and Java Script -when we drag and drop the controls then unwanted html and java script is automatically inserted in our code that's why page become heavier and it takes time to load on browser. View state -One of the main problems with ASP. NET web forms is the viewstate mechanism, which takes a lot of bandwidth because it serializes all the form inputs and sends it on post commands.
On the other hand we can say it provides Sepration of Program logic from the User Interface. This is where ASP. It started out by a rebellion of developers who called themselves "Alt. Net" who wanted to get back to proper and pure software development principles. No more muss and fuss, just focus on business objectives and software best practices.
Note that HTML is already a very high-level markup language, as is Javascript a high-level programming language. The whole story would have been different if we were dealing with Assembly language and C. Expanding upon 2, then, another objective of ASP. NET MVC is to enable developers to organize the front-end details of the 'view' portion of their solutions and take advantage of the rich foundation that the rest of the industry has built upon the front-end client platform.
You will find that ASP. NET MVC developers feel at home utilizing rich Javascript libraries and client-side templating techniques without fighting with the server-side architecture. This was not originally the case with ASP. I am a complete and total convert to ASP.
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 then 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. 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.
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.
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.
My 2 cents is to always use ASP. In my opinion, webforms is not a good way to develop web apps, period. I have read all the answers and feels my personal experience would add something to the answers above. 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.
For someone coming from windows development, Web forms will always be favorable. For someone coming from web development in some other technology, MVC will be favoured since it mocks the latest of them all.
Deployment is still an issue. In web forms one just needed to do copy and paste. But, this requires some things to be done. I've not seen this consideration put forward amongst the existing 15 answers to this thread yet, but I think it's worth considering. 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.
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 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.
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. 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. Is this really such a big deal? 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. 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.
In my opinion, they are related enough and have roughly the same capabilities that it should come down to preference. 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. 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.
When faced with a programming problem I often look to the web for answers. 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. Well, WebForms 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. Unless you can spend the money and effort to get your guys as proficient in MVC as they are in WebForms applications, you're undoubtedly going to try and hold off upgrading to the new platform for as long as possible.
So it presents several logistical problems: Do the benefits of MVC outweigh the cost in terms of lesser quality and deployment time? 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 WebForms.
When I worked with WebForms I saw data controls, state management, modularity, composition Html wasn't the case or focus. Sign up to join this community. The best answers are voted up and rise to the top.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. When to favor ASP. Asked 10 years, 3 months ago. Active 4 months ago. Viewed k times. I know that Microsoft has said ASP. Improve this question. Darknight You obviously have a poor understanding of MVC if this is your opinion There are some huge sites built with mvc 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. Show 17 more comments. Active Oldest Votes. I felt there were too many files for 3 pages, but that is my personal opinion.