ASP.NET: officially unmaintainable

Recent forays back into “classic” ASP.NET (i.e. not MVC) have me completely convinced that ASP.NET is inherently unmaintainable.  Not partially convinced, not on the fence, but completely convinced that the presentation layer of ASP.NET cannot be maintained in any reasonable manner.

I remember a presentation on MonoRail some time ago, where the presenter asked the audience “how many of you work with ASP.NET in a professional manner?”  A hundred or so hands went into the air.  The presenter then asked, “Now keep your hands in the air if you actually enjoy working with ASP.NET?”  Only a handful of hands stayed in the air.

Now, obviously some peer pressure skewed these results, and it wasn’t a double-blind survey, but it was clear that developing with ASP.NET is a frustrating experience.  My own personal frustrations include:

  • The ridiculous amount of time I spend in Reflector trying to figure out why things that are supposed to “just work” when wired up “just don’t”
  • Not having control over the HTML that is spit out.
  • Trying to do anything with AJAX or DHTML with the insane control names
  • That ASP.NET is the king of leaky abstractions

I try to make the ASP.NET layer as thin as possible, so that the bulk of the application is maintainable.  But even in a MVP setting, the V is still dreadful to maintain.  In the end, HTML is the application, not controls.  HTML is what gets delivered to the client, not crazy post-back event server nonsense.

I knew early on I would have troubles with ASP.NET, back in 2003-4 or so, when I had to use Reflector to get even basic scenarios to work with a DataGrid.  Debugging why control event isn’t getting fired pushes my sanity to the brink.

It also doesn’t help the fact that I’ve never seen an ASP.NET application with unit tests for the code-behinds.  Without tests, your code is unmaintainable.  Since you can’t unit tests code-behinds, you have an immediate charge in your technical debt.  For this reason, I can’t really recommend using plain ASP.NET, almost ever.  Using a real MVC framework in MonoRail was not only a breath of fresh air, it felt like I was the frog getting rescued from the pot of boiling water, never noticing the temperature going up.

So do yourself a favor, take the one week MonoRail challenge.  Try building one aspect or one story in MonoRail, and see how it feels.  Personally, it felt like a crushing weight was finally lifted.  You might feel the same, and with a one-week spike (or even one day), what have you got to lose?

About Jimmy Bogard

I'm a technical architect with Headspring in Austin, TX. I focus on DDD, distributed systems, and any other acronym-centric design/architecture/methodology. I created AutoMapper and am a co-author of the ASP.NET MVC in Action books.
This entry was posted in ASPdotNET, MonoRail. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • LOL!

    I sure feel this way sometimes.

  • Michael

    Just to be clear, you’re actually referring to WebForms not ASP.NET? Right?

  • I have decided that I will not go back to ASP.NET (WebForms) unless someone pays me _gobs_ of money. I’m a big fan of MonoRail and looking forward to the advent of ASP.NET MVC.
    Funny enough, I did some “classic” classic ASP not too long ago, and found that it was as painful as I had remembered!

  • @Michael

    Yes, “WebForms”. Thanks for the clarification!

  • Preaching to the choir… I’m very tempted by your MonoRail challenge though!

  • Aha, that’s why I’m so unmotivated right now: Web forms foo. And it is totally a boiling frog scenario. I had no idea of the pain. In fact, I remember when I thought web forms were really cool. Hmm… MonoRail.

  • Jeffro

    Have you had a chance to compare MS MVC with Monorail yet? I’d love to hear about the pros/cons between the two.

  • I’m currently taking the MVC challenge. It does feel a lot lighter than ASP.NET…

  • Mark

    Works On My Machine

  • Matt

    I would have been one of those people who put their hand up in that conference.

    Sure, the Page is a leaky abstraction, but I work in a place where we make user and server controls for our designers to use in our sites. The level of functionality you can encapsulate in a server control for extremely easy use is pretty much unmatched by any other web technology I have used before.

    If I were using *Views with *DataSources I would probably agree with you, but WebForms do address a relatively large problemspace. Maybe not as big a one as MVC style frameworks do, but it is not useless.

  • I’m offended by this post. I have spend a significant percentage of time in my career studying and memorizing the ASP.NET Page Lifecycle and i know all the intricacies of CreateChildControls and which events fire when you add a control to the Controls collection.

    How dare you assault the castle of knowledge I have built!

    Seriously, though, I have a friend who is still running a significant ASP app and I looked at his code again recently and I’m thinking that ASP as a view engine with .NET behind is looking pretty darn good right now.

    That’s essentially what ASP.NET MVC is, I guess.

    Anyone ever think: “Wouldn’t it be easier if you could just give me three Dictionary‘s: Request, Form, and Session and an output stream and I can take care of the rest?”

    I guess that’s what CGI is and that didn’t work out too well.

  • Tim C

    Convince me that webforms sucks. Show me code that sucks / is impossible to maintain in webforms that is freaking awesome / easy to maintain in monorail.

  • Alex

    Oh yeah tell my boss that i will take n ( 2, 3 ?) times more to do a data entry app. He sure will love to know about viewstate mess and stuff.

    People want applications and want it fast. Webforms do.

  • I agree that WebForms makes it so easy to commingle presentation and business logic, that unit testing a web application is difficult at best, and page lifecycle issues can be nightmarish. The Postback model is great for simple pages, but I think it quickly becomes an albatross around the neck of larger applications.

    On the other hand, I see a lot of value in the extensible WebForms component model. At my current company we have a number of reusable user controls that improve consistency and maintainability. Is there a similar story for creating reusable UI components in MonoRail or ASP.NET MVC?

  • ReTox

    > Trying to do anything with AJAX or DHTML with the insane control names

    I would also note that this madness with IDs makes CSS also painful

  • @Seth

    Depending on the view engine used, they all have some concept of view components.

  • Andy

    I second this.

    Convince me that webforms sucks. Show me code that sucks / is impossible to maintain in webforms that is freaking awesome / easy to maintain in monorail.

    Not every app has to be a pillar design and technology

  • @Alex

    Fast is relative. Fast works for about 2 weeks, then fast becomes slow. I’m not working on 2 week disposable apps. I’m working on apps that have to live for longer. In that case, since 60-80% of development cost is in the maintenance phase, after initial development, I’ll optimize production towards that end.

    That means a maintainable ecosystem.

    In any case, I’ve found I develop RAD apps faster in MVC style anyway. Check out all of the RoR apps out there, those are MVC and the conventions lead you down the right path.

  • Tim C

    >I would also note that this madness with IDs makes CSS also painful

    Why? If you are intent on using CSS to apply to IDs of elements, then wrap your control inside a div/span that has that ID. I’d hardly call that painful…

  • @Tim C:

    Now I have to do EXTRA work just to get around limitations in WebForms.

    Whatever short-lived productivity gains I may have accomplished during initial development start getting eaten up by stuff like massaging my HTML in order to get around the ridiculously_long_control_id’s.

    With [pretty much every other web framework] I don’t have to do this.

  • Sounds good, I’m taking a look at monorail right now!

  • Onur Gumus

    I am a senior web dev. I haven’t programmed with monorail but I peeked and know the idea. I also have developed full blown applications with rails and flex.

    Web Forms Cons:

    Hard to unit test: You have to use MVP like strcuture. Which can be overkill

    Viewstate: View state is a complex mechanism and can slow down your application

    Page Life Cycle: This is also very complex and hard to learn

    Generated HTML is untouchable: You have no control over the generated HTML. This makes very difficult to use 3rd party frameworks


    Distance from HTML: I never liked Html so gives some distance from html. With monorail you have to type a lot of html as well as mvc. This was also the case I quit from rails. Html is crappy and must be abtracted

    Component and Event Driven: This is a great issue of ASP.NET Web forms, you can encapsulate every peace your page into sub components. This makes your application very maintenable. With MVC you would have only html snippets . And although ASP.NET MVC supports web controls not the post back ones

    Ultra easy ajaxifying: You can make any of your custom component ajax enabled just by putting it into an update panel. Same effect is dificult to achive with MVC farmeworks even if you use JQuery, ExtJs, dojo.

    Ultra powerful: Have you checked ASP.NET Ajax Client Library. The logic behind is very good. Most ajax libraries are focused on widgets or communication stuff. MS client library is for interconnecting any javascript library with your components very powerful

    Built in caching: Very easy partial caching or full caching

    To sum up, I still prefer Web Forms, and I can’t see any better technology despite the criticism. I can understand the criticism since Web forms is hard. I mean real hard. It is not as easy as ms promised or shown in their demos. when you dive in, you can be frustrated with the complexity which is why most people are disappointed. But that doesn’t change that web forms is extremely powerful.

    Try to do an ajaxfied gridview with internationalized sorting support + editing+ deleting. No even extjs can’t do it

  • I think is great to work with, maybe that’s just me. The learning curve is a lot higher than classic ASP or PHP (I haven’t used MonoRail) but once you understand things like the page lifecycle (events) and a number of the other concepts of, it becomes a great language to develope in.

  • I disagree. I came to ASP.NET from Classic ASP/VB6 and I really enjoy developing in ASP.NET more. Yes, there’s a bit of a learning curve compared to Classic ASP, but the development platform is extremely better.

    And, as for working with controls using JavaScript/AJAX; all you have to do on the server to get the client-side ID of the element on the page is: [control].ClientID

  • @Chris

    ClientID is non-deterministic, which makes it tough to use CSS or the myriad of javascript frameworks out there (jQuery, prototype, etc.) I know that it’s there, but it’s a kludge.

  • I’m sick of people who don’t understand webforms, and then complain about it.

    A poor builder always blames his tools.

  • @Dave

    A poor debater discredits the opposite point of view, rather than address it directly.

    Six years of understanding WebForms is enough. There are better models out there. If you chalk up my arguments to lack of understanding, your biases have led you to gloss over any contradicting analysis.

  • I think I worked into ASP.Net WebForms backwards from the traditional path. Most Sr. people I’ve worked with began as backend coders and worked forward (towards the UI). Thier frustrations sound a lot likes yours. I started out as a ‘wet behind the ears’ DHTML developer and worked towards the lower level functionality my peers were experts in.

    I am not going to defend DHTML as a simple, straight foward medium, but I’ve plumbed the depths of WebForms to the point that I find them easy.

    Re: Control over the HTML output.
    True, this is not accessible from the ‘out of the box’ controls, but if you create your own class that inherits, say, RadioButtonList and overload the Render method, you can have complete control over the output.

    I understand the frustration with the Control Event Model, but it’s just part of working with a disconnected layer like the web. Are there better implementations? I am sure. I seldom have to resort to using Reflector, the debugger + online info has worked well for me.

    AJAX and DHTML – see above. That’s what I started in, I don’t find it difficult anymore.

    Page as a leaky abstraction later. Ok…..I guess. I just haven’t run into where this has been a significant detriment. When you analyze any framework down to it’s lowest levels, I guarentee you will find thing implemented in a less than optimal way. That is the trade off when using a framework that abstracts away complexity.

  • Glenn

    Wow, after reading this post I can now understand why some people think the ALT.NET guys are a bunch of douche-bags. Spurious inflated claims that aren’t even well supported. No wonder the ALT.NET community gets some eye-rolling when they have people like you claiming to represent them.

    ASP.NET is officially unmaintainable?
    Truth ~ Jimmy Bogard doesn’t like ASP.NET’s WebForms model. It may not fit well into what he’s doing. Or it may be that he’s having a hard time learning it. Either way the fact remains that thousands of people and projects use ASP.NET for many different things.

    Want to know why all those people raised their hands? …Exactly because it is successful.

  • @Glenn

    I’m tempted to just delete the comment…I had the courage to use my full name and attach it to my ideas, it’s unfortunate that you did not.

    Thousands of people use it _only_ because it’s there. They raised their hands because it was at a .NET user group meeting.

    I never said WebForms isn’t successful. It’s just the wrong abstraction of the web.

    Again…shallow analysis has led you to the “oh geez what a complainer…he must not understand it” observation. My contact information is in the “Contact Me” link. I’d be happy to engage in a real conversation, if you like.

  • @Aaron

    If I’ve overloaded Render, haven’t I already lost? What value is the control providing? RadioButtonList is nothing more than a for loop in the template for HTML INPUT tags.

    Reminds me of the conversation on Haack’s site – “We need an MVC Repeater” “No, it’s called a for loop”.

  • I use quite extensively and have built and developed many applications using since .net 1.1

    Just use JQuery. Learn it, use it and find a way to make it work nicely with everything else. When you hit a snag or challenge, research and develop a solution. Thats development. Move on and do the next thing on the list…

  • “then fast becomes slow”. Agree. Additionally I personally think that is too much of finding out when and where to do things. I.e “not in Page_Load, you must do that kind of thing in Init, or CreateChildControls” etc.
    Last, at least to me the cost of the pagehandler and viewstate simply isn’t worth it, I am currently looking into my own lightweight asax handler using another sort of template engine for gui.

  • I’ve done development in ASP.NET and MonoRail. I did enjoy MonoRail however for my last web project I decided on django and enjoyed the experience even more.

  • Thanks – this needed to be said explicitly. I’m disappointed by the negative reactions, as it seems pretty obvious to me to ASP.NET Web Forms is broken, and that people at MS recognize it.

    The idea of letting .NET developers build Web applications like Windows desktop applications wasn’t a stupid idea at the time, and applying it did give real benefits. Unfortunately it turned out that many things around desktop development were flawed, and the Internet pushes things past their breaking point.

    It’s not just that Web Forms doesn’t play well with the Web frontend stuff of today, but that you have to compromise at every level to accommodate it. At the very least, ASP.NET MVC provides something that enables clean separation, so that we can more easily do the things that we now know that we need to do to effectively maintain data-driven network applications.

  • MrTea

    Thanks for this post. Some of the negative replies appear to be on the same level as Xbox/PS3 fanboy posts in terms of their aggression and failure to engage in a debate.

    ASP.NET web forms did a good job of taking asp/html web site “developers” and leading them down the path of software development. For a lot of people it was their first exposure to the power of server-side programming and as such has served an important purpose for a number of years.

    However to be good at what you do involves continuous learning (including making mistakes) and this applies to the guys who create the frameworks as much as it does to those who use them.

  • gordonz

    Your comments on Web Forms definitely hit the problem nails on the head. I’m a sr. dev and I’ve spent a lot of time and energy learning the framework, determined to get the most I could out of it, and learn in the process… that’s my point. Just because Web Forms is a flawed tool doesn’t make it useless.

    If I never wrote another Web Form app in my life, the time I spent learning Web Forms would still be time I would look back on and cherish as a time of great personal growth as a developer. It was my second web development framework – I first began with a couple of years of JSP but immediately won me over from JSP and all those Java app servers. At the time, it was mostly C# that did it but I don’t want to get into that one!

    As I got deeper into and web development in general, experiencing’s shortcomings, looking and experimenting for a better way to do the things that were frustrating me, are the very things that made me a better web developer. But there’s one thing I can’t deny – the incredible feeling I had when I wrote my first MonoRail app. It was one of those “aha!” moments all programmers live for, the clouds parted, the sun shone brilliantly. The Castle Stack is now my favorite development environment because of the things I’m now learning from it.

    But I definitely do not think it “officially unmaintainable.” I don’t think the MVP variants are overkill any more than MVC is. With Passive View I don’t need a page-behind. With Supervising Controller it’s just wrapping presenter calls, no application logic included at all… in fact you NEVER need a page-behind.

    Yeah, so the Page and the runtime pipeline abstractions may be seriously flawed in some respects. Your absolute control over the html is taken away, and this may not be right for the work you want to do and the way you want to do it. But Web Forms are not un-testable or unmaintainable.

    They ain’t easy, and they ain’t pretty, but they work. Of course, given the choice of a Web Forms project or a MonoRail project I’d jump on that train so fast you wouldn’t believe it!

  • vzMdOC tkkdzpxuvfri, [url=]fgnrcitgplpj[/url], [link=]nevghfbtiqrb[/link],

  • AAA

    I must agree with you, Im trying one smaller app with ASP.NET, because you can “fast click: your application and test your backend. But what a hell even on one page. And I once kept maintenance of older ASP.NET application for secretary of transport. No one had enough courage to change anything, application was working only sometimes… Data bound controls were broken and I had to repair it. Of course, those were repairs with some magic and not maintainable into the future. I dont reccomend it. It is good for some fast school projects, but thats it!