Abandon ASP.NET WebForms!

Just abandon ASP.NET WebForms – the sooner You realize that – the better for You.

At the begging I would like to say that I used to be a BIG fan of ASP.NET. Before my experience with Microsoft technology started I had some really bad time with php and mysql. But that was some long time ago – in the begging of this century. Then I started playing with ASP.NET – and I really dig into it. Managed code, simplified views by use of controllers, postbacks, viewstates, widly used provider classes  - for sitemap,  database. It all looked just GREAT! I had barely any knowledge of web (html, css) and I was still able to make cool websites.  You just drag and drop button – you double click it – and You immediately get place for Your code for handling button’s click event. Yeah! Event-driven web development – that sounded exacly like something I was doing so far in windows applications.

Somehow, the longer I was playing with that, the more confused I was. All the pros suddenly showed up to be not as cool as they looked like at the beginning. Viewstate become a performance issue, I ended up compressing it, turning it off here and there.  Sooner or later I needed new functionality for controls – I ended up writing my own. Those provider models were not really “test friendly”. A sort of a turning point was when AJAX showed up. You make AJAX callback – You go through all stages for of page life cycle.  What?! I need that much to change so little.  Because I was trying to stick to Microsoft technologies and not really look around, I accepted the fact – web development is painful – it is just how it is.

The turning point was at the end of last year(2008). I was working on medium project for one of local companies. Company is small – has just a few developers. Project was just about to end when I had talk with my boss from US. I looked sth. like that:

- Boss: We are just about to release beta of our product, I talked to some web designers to make a new look for our web site.

- Me: Yeah! It sounds great!

- Boss: They will need code so that they can prepare come CSS for us…

I never consider myself a CSS guy, Our web site was functional but sort of ‘ugly’ one, so it was a big relief for me. I prepared code, send it and made sample web site public. After stg like month I received PDF file with screen-shots of Our new website. It looked just great. Everything was clear, simple and yet really eye-catchy.

Two weeks after I had approved It I received long-waiting HTML and CSS styles. And I was shocked! It looked like those designers never looked at code. What they have made will force me to write completely new rendering of nearly all used controls (navigation, gridview etc.). I was really, really angry. At the begging I was angry at my boss for not making sure we leave it to people that know sth about asp.net, then I was angry at those designers. Finally, when I calm down I realize that actually problem lies somewhere else. Let us face the fact – why those designers need to know anything about asp.net. They prepared styles and html for a view. View has nothing to do with page flow, controls and logic. It is just a View – presentation side of Your application. How the hell they should know about OnRowDataBound?

I realized – and that was painful – that WebForms does not force developers to write loosely coupled code. By providing, or better say: allowing,  page or controls events it destroys separation of concerns. Somehow view, control and business logic overlays each other. By adding ViewState it hides basic property of html protocol – it stateless. WebForm’s design make developers dumb. I am 100% serious!

So, my suggestion: Abandon ASP.NET WebForms if You can! Yes, You can! There are a lot of nice alternatives, including ASP.NET MVC, Pythod Django or Ruby on Rails. I really become fun of MVC framework – especially if it concerns web development. One of Microsoft MVP wrote that “You should at least learn ASP.NET MVC”. I would go further, You can not afford not to learn it.

Share

Related posts:

  1. Web designers vs Web developers
  2. Client side validation after Ajax Partial View result in ASP.NET MVC 3
  3. ASP.NET MVC 1.0 issue within HtmlHelper.GetModelStateValue method
  4. jQuery style Ui dialog over flash banners
  5. Tips for jQuery validation plugin

31 Responses to “Abandon ASP.NET WebForms!”

  1. Kelly Brown says:

    I really like your post. Does it copyright protected?

  2. ITmeze says:

    Kelly Brown :

    I really like your post. Does it copyright protected?

    No, It is not. As long as You are okay with my English :)

  3. [...] to Vote[Del.icio.us] Abandon ASP.NET WebForms! (6/19/2009)Friday, June 19, 2009 from itmezeJust abandon ASP.NET WebForms – the sooner You realise that – the [...]

  4. jbland says:

    great post. definitely another perspective to be considered.

  5. Chris Love says:

    I agree with you. I have been writing a series I call ‘Thin ASP.NET’ the last few months. I have weened myself from web controls as a new years resolution. I love it, I am free. I chose not to go down the MVC path, I guess I did not see the need for it yet. I can test things, why retool all over again? http://professionalaspnet.com/Default.aspx

  6. wicherqm says:

    I dont agree with you.
    It is not problem with dumb asp.net forms but dumb asp.net developers.
    If developer is dumb then if het get another language he do the same.

  7. Simone says:

    Great write up… but you are right… ASP.NET MVC takes the web back into Web Development.
    WebForm has its space, as it helps building web portal quickly (at least the UI part of it), but it’s PITA when you want to finely tweak the HTML of your page: sure, you can do it, but doesn’t mean it’s easy

  8. ITmeze says:

    @wicherqm
    I do not consider ASP.NET web forms dumb. What I was trying to say Is that there are far better alternatives.
    @simone
    Exactly, I am having fun making web again!!!!

  9. Abandon ASP.NET WebForms! | ITmeze…

    Thank you for submitting this cool story – Trackback from DotNetShoutout…

  10. Glen says:

    Thanks for the great article! I’m so glad the .NET community is starting to come out of the Microsoft bubble and face reality.

    As a front end developer (yes that’s the XHTML/CSS/JavaScript dude) I go through ASP.NET hell every day. As a side job I develop on PHP platforms and frameworks such as Drupal / WordPress and would love to work with these full time. For the record, I used to do old-fashioned ASP for a living (1999-2005).

    I recently had to learn to become a SharePoint web developer at work. My expectations were high, but then the reality hit in that SharePoint is a 100 times worse compared to plain ASP.NET when it comes to the control you have of the HTML output.

    Sadly, this is the Microsoft story over and over again. They keep neglecting standards and come up with their own in an attempt to dominate the market, but end up being a threat and hindrance to the development of the web. Take IE6 as an example. That piece of s*#t just won’t die! And it’s because of IE6 (and even IE7) that we don’t see advanced and rich user experiences dominating the web, even though it’s 2009!

    I really don’t care what Microsoft comes up with to enable the business and data layers of a web application, as long as they leave the VIEW alone! Thankfully ASP.NET MVC is a step in the right direction, and so is the more standards compliant IE8. Unfortunately it will take some years still to shake off the damage done by ASP.NET WebForms as well as IE6 and IE7. Those years in web years will seem like a lifetime :(

  11. Onur Gumus says:

    “Viewstate become a performance issue, I ended up compressing it, turning it off here and there.”

    This is mostly incorrect if you are really not blind. The viewstate can be turned off for individual controls. And even fine tunning is possible in asp.net 4.0. With compression this is rarely an issue.

    “sort of a turning point was when AJAX showed up. You make AJAX callback – You go through all stages for of page lifecycle. What?! I need that much to change so little.”

    This is also incorrect, you can make json calls to web services and page methods easily if you need.

    “I realised – and that was painfull – that WebForms does not force developers to write loosly coupled code. By providing, or betteer say: allowing, page or controls events it destroys seperation of concerns. Somehow view, control and business logic overlays each other. By adding ViewState it hides basic property of html protocol – it stateless. WebForm’s design make developers dumb. I am 100% serious!”

    This depends to you. Just apply MVP pattern and you will have a nice seperated code with testability.

  12. ITmeze says:

    @Onur Gumus
    1. I am not saying You cannot turn off ViewState. I should have turned off ViewState for whole page at the very begging of the project life cycle. After some time, when ViewState become performance issue It is tough to completely remove it without some extra efort.
    2. I was using UpdatePanel (ASP.NET 2.0) – as I assume this is sth MS prepared for ajax requests. I know there are changes in AJAX for ASP.NET 4.0 that make partial rendering more effective…
    3. You can make web forms pretty testable as well. But I wouldn’t consider it straightforward.
    At the end just imagine situation You are senior developer and You want to explain to the guy that have just finished university and have done few asp.net tutorials: “Turn off ViewState”, “don’t use update panel”, “don’t play with controls”. He can be pretty much confused.

  13. Omnibus says:

    Nice post, but it says a lot about how bad is “hardcoding”.

  14. I wholeheartedly disagree with this posts overall goal, the abandoning of ASP.NET WebForms. As a precursor, I do really like MVC and it is a very powerful implementation available for .NET with the support for RESTFUL software development. Now with that being said, WebForms still has a very clear use which is generally web application development. Editing grids and manipulating complex data structures are very clear uses of where WebForms really shines in it’s development. The other big feature of WebForms is it allows you to design applications that function the way 90% of end users EXPECT an application to function.

    A MVC website behaves nothing like an application and (nearly) solely as a basic html page. This is a huge divergence in usage from the way business applications are expected to function.

    Your statement about having to redesign your whole website to accomondate their html / css comes from the lack of care in designing your website. If you take advantage of controls like the ListView control that allows you to very formally define clean html output it starts to become much easier to write CSS complient sites. It’s also important to take a seperation of concerns pattern into your web development, like the Model View Presenter (MVP) pattern which will stop you from using the code behind to mess with whats going on in the page in the wrong way.

    Proper use of a tool is what makes it a good tool. MVC has it uses and so will WebForms and it will for a long time. I find it extremely unlikely that the MVC type development will take over business application development for 2 reasons, one being what I’ve mentioned numerous times already is that it changes the way users need to expect how to use the application, the second reason which this one makes me sad is the fact to develop with MVC you really do need to go back to understanding HTML, CSS, JavaScript (JQuery FTW) and write good clean markup which it seems the majority of ASP.NET developers that design IE6 sites cannot and carenot ever to do.

  15. I have to agree with Chris, this article is not really based on any kind of sound argument. ASP.NET Web forms are a masterpiece of creative thinking when it comes to speeding up the Web development process in general. But I guess this is one way of gaining traction for a new blog? ;-)

  16. SanjayU says:

    While I am not discounting RoR, Python, or MVC (In fact I love MVC) I do think there is a slight problem with this. To me the sign of a true craftsman is the ability to select the proper tool (approach, etc.) for the job. I’m not saying WebForms will necessarily be that tool often, but I don’t think it makes sense to abandon what of the tools in your toolbox.

  17. ITmeze says:

    @SanjayU
    I can image situations where web forms works better than mvc. But going this way I can imagine case where static html works better than web forms. I am not trying to generalize. There are some web form components or controls that speed up web development (especially charts). But I guess it won’t take much time to adopt them to asp.net-mvc. As a matter of fact it is just string output at the very end :)

  18. @Chris Marisic:

    You state that ASP.NET MVC “changes the way users need to expect how to use the application”

    This is just incorrect. You can build anything in MVC that you can build in Webforms. It is just a lower level way of doing things that gives you more control over how things are done. Also you can have very functional editable grids in ASP.NET MVC that match or surpase the gridview and it’s ilk. Take a look at jqGrid, DataTables and or ExtJS grids.

    Nice article. It echos my experience quite closely. I now do a lot of webforms development because I must, but I much prefer doing ASP.NET MVC.

  19. ITmeze says:

    @Trevor de Koekkoek
    I can not count times at my job – when i am forced to use web forms – when I wish I could have used asp.net mvc

  20. Really nice write up. I like how you spoke from experience on how one approach better suits your needs rather than being all dogmatic about the change.

    The one thing that developers often forget is that they get paid to solve problems, not re-invent wheels. :) So in order to solve problems, you must be willing to look at all possible solutions even if they take you out of your comfort zone.

  21. Zeph says:

    If you want people to take your blogging seriously, take the time to spell check your posts.

    This blog post is littered with over 20 typos and misspellings. Ugh.

  22. ITmeze says:

    @Zeph
    Thanks for letting me know. I guess at the time of writing my Chrome didn’t have a spell checker :)
    English is not even my second language :)

  23. SanjayU says:

    @ITmeze
    “But going this way I can imagine case where static html works better than web forms…”

    And that, my friend, is the *correct* logic to follow. Are you implying Webforms (or any “development language”) is better than WebForms for every task?

    This is exactly my point, the best tool for a task is going to vary. That tool might be WebForms, static HTML, MVC, etc.

    Saying tool X is better than tool Y in all scenarios is simply incorrect.

  24. Yes, maybe the problem is the Web Forms incorrect usage.

    But the problem is, it’s easy to do that, and a lot of people are doing crap on top of it. A lot of *developers* become used to do things in a bad way.

    I think MVC is a more opinionated approach, and it can help us to achieve good engineering practices.

  25. mike says:

    @SanjayU
    I got Your point, my friend. But You still don’t get mine. Let us blame my English for that :)

    @Rafael
    Web Forms incorrect usage is one point. Another point is that I truly believe it does not serve web well. You are right, MVC forces us to archive good engineering practices.

  26. @Trevor de Koekkoek
    If you spend the level of effort it takes to make a MVC site function like a WebForms site, wouldn’t it have better off using WebForms and using that time to actually develop something meaningful?

  27. Loukas says:

    Do you think that using an MVC framework would make your life easier? I guess what I am trying to say is that your example of the site redesign would be a pain using MCV or not…

  28. Stuart Ellis says:

    I tend to agree with Glen’s point – Microsoft tend to want to do their own thing in every field (for better and for worse), but these days the Web is bigger than Microsoft’s ecosystem, so when they reinvent wheels in this area now they just create a (large) ghetto.

  29. Hello. I think the article is really interesting. I am even interested in reading more. How soon will you update your blog?

  30. Bill says:

    Great article. I totally agree with every word of it.

    If webForms was so good then why do we have “MVC”?

    The famous answer is : “…there is a place for each….”

    Sure…sure… :)

  31. Scott Fletcher says:

    Thanks for the article. I had completed my ASP.NET MVC project and felt not liking it with the way the MVC folders & Areas are designed, making it too easy to get lost or wrong files. YOur article made me take a step back adn take a deep breath. I’m now getting started on cloud computing as I was debating on which technology to go with. Thanks.

Leave a Response