There are three ways now to write a web site in ASP.NET:
- Use Classic ASP model with everything in the ASPX file and only use HTML controls without the runat=”server” attribute
- Use the Web Forms model
- Use the new ASP.NET MVC model
Each have their own benefits that need to be weighed carefully prior to moving forward with a design. So what does MVC give us that we didn’t already have in either classic ASP or Web Forms?
The classic ASP model has as its primary benefit the fact that it is a familiar model to most web developers and allows us to write lightweight code. See my post about why classic web developers have trouble with ASP.NET for a larger discussion on this topic. Other than it being familiar, you might also use this for a simple web page that doesn’t really do anything (static content) or a “one off” application that has very few pages. However, we all know that “one off” pages end up being larger applications where an application benefits from a defined architecture. So the only good reason for using this model would be that it is a lighter-weight model than what we might otherwise have with ASP.NET’s Web Form model.
Web Form Model
The Web Form model’s primary benefit over the other two models is that it allows you to create an application quickly with a semi-predefined architecture. The downsides are that it tends to have more on the client side than it should and you really have to understand event based programming to get it to do everything you’d want it to do, something traditional web programmers are not familiar with and struggle with when they first meet ASP.NET Web Forms.
To be clear, most of the detractors to the Web Form model can be eliminated if you fully understand how it works. For example, you could purchase or build an HttpModule that handles state management on the server instead of in a hidden form field, or you could simply turn off state management.
If time to market is your most critical determining factor, ASP.NET will probably still be your choice.
ASP.NET MVC Model
So what does ASP.NET MVC give us that the others don’t? Primarily it gives us a more granular separation of concerns and eliminates the overhead associated with Web Form controls. Not that we can’t use them, but we don’t have to use them to take full advantage of the model.
For people coming out of a Java/JSP web development background, ASP.NET MVC is going to look a lot more familiar than either classic ASP or the Web Forms model.
However, for those of us already comfortable with Web Forms development, I’m afraid MVC is going to seem like a step backwards.
This isn’t to say that it shouldn’t be used. Just that there is a learning curve associated with this new model as there is with any model.
If you need a high performance web site and are willing to put time into learning this new model, ASP.NET MVC might just be for you.
One type of web application that might benefit from this new architecture is one which is primarily AJAX-based using a lot of JSON calls to web services.
That is, because you are avoiding postbacks, you wouldn’t be using Web Form controls anyhow. In this case, you’d either need to roll your own architecture or you’d want to adopt one that fits what you are doing on your site. I always opt for using something someone else has created.
If you’ve been using the classic model, you really should drop that and use MVC instead. Classic is architectureless (is that a word?) and having architecture is always better than no architecture.
Do you really need it?
Microsoft has made it pretty clear that ASP.NET MVC isn’t for everyone. It is a way of programming a web site that has specific benefits to a specific class of programmers and/or organizations. It is not THE way to program ASP.NET.
My fear for us as programmers is that many lead programmers will convince their organizations to move to this new model simply because it is new and therefore better. Because they want it on their resume. Rather than because there is a strong business case for moving to this new architecture.
Be careful to choose the right tool for the job. Not what you know and certainly not what you want to put on your resume. Just because it is new, doesn’t mean it is greener.
Other places talking about ASP.NET MVC:
Chapter 4 – Understanding Views – Therefore, if you want to test the views in your ASP.NET MVC application, you must seek an alternative. In this section, we discuss three methods of testing your views that do not depend on the default Web Forms View Engine. …
WebForms or MVC? What about the third option? – The ifjernsyn.dk website is so plain simple that ASP.NET MVC would fit just fine. Why botter to coin a new term to develop a site like that. ZeroForms is WebForms, but may have a better performance, as many bloated things of WebForms is …
Less Than Dot – Blog – Learn Visual Studio 2010 now by watching … – We’ll begin seeing how Visual Studio 10 and the .NET Framework 4.0 offer compelling new functionality for web developers. In this episode we’ll be specifically focusing on ASP.NET WebForms 4.0, and what enhancements it offers. … is designed to help you learn how to utilize the Visual Studio 2010 features and a variety of framework technologies including: C# 4.0, Visual Basic 10, F#, Parallel Computing Platform, WCF, WF, WPF, ASP.NET AJAX 4.0, ASP.NET MVC Dynamic Data. …
Is Classic WebForms More Mature Than ASP.NET MVC? : Jeffrey … – In my last post about ASP.NET MVC , Jeff Gonzalez referred to WebForms as “Classic ASP.NET”. I had to take notice since when ASP.NET can out, we spoke about “Classic ASP”. This mere reference is interesting. His comment goes on to talk …
Shawn Wildermuth – Building AgiliTrain: Part 1 – Why ASP.NET MVC – That’s pretty close to my experience. I thrashed for a couple of weeks wondering whether going back to WebForms would be faster…but I was patient. I talk to some people about their fears of ASP.NET MVC and the big one I hear is lost …
Other post in ASP.NET MVC
- ASP.NET MVC - Model != BLL or DAL - February 11th, 2009
- ASP.NET MVC - Is The Grass Really Greener? - February 24th, 2009
- MVC - Let's Install it. - March 19th, 2009
- ASP.NET MVC - Routing - March 26th, 2009
- WebForms vs MVC–The War Is Over - September 25th, 2014
- ASP.NET, Angular.js & html5mode - September 24th, 2015
- Using Node.js and Gulp with ASP.NET in Visual Studio 2015 - January 21st, 2016