ASP.NET Web Forms: This all feels wrong to me!
February 28, 2015 9:02 AM   Subscribe

I am taking a class in ASP.NET web forms to make web sites after learning how to make web sites using front end tools with MVC for server stuff. Everything I'm doing seems at odds with what I've learned in the past. I'd like to know how web forms are used by professionals doing actual work.

Last semester I took a class that I would describe as a front-end web development survey class. I learned a lot of concepts around JavaScript. JQuery, AJAX, JSON and how they work with HTML documents. My instructor was the lead front-end developer for Progressive Insurance and he had us do a lot of work in Visual Studio, using ASP.NET MVC code for which he wrote the server side code. So, in the course of the class I learned a bit about MVC and really understood the benefits of how it works. The instructor did a very good job explaining how developing in this environment works in a professional setting and I really understood how the work I did fit into that setting.

Cut to this semester and I am in an Active Server Pages class. We are doing all of our work using Web Forms to make web sites. My problem is I don’t completely understand the value of it or why work would be done in this way. When I’m working, I am making functional products, but it feels as though the back end and the front end are a jumbled mess that can’t be extricated from each other. Writing asp server controls in web forms seems so backwards compared to creating HTML pages that use front-end scripts to call back to the server.

To make things worse, these are online classes and, whereas my front-end instructor was very available and great at giving feedback, this instructor basically tells us to read the book and do an exercise. My last instructor would put together helpful extended lectures on the topics to watch, whereas this instructor does very little of that.

I feel like if I understood how developers use web forms professionally, I would better understand the why of what I’m doing which would help me feel motivated to better understand the how. So my question is, how does the ASP.NET web forms work flow function professionally? Also, are there any good resources I can look at to see how dev teams use ASP.NET in the field?
posted by coreywilliam to Computers & Internet (10 answers total) 4 users marked this as a favorite
Maybe a little history would help? Web forms were intended as a way to integrate Windows forms-style controls into web development, in order to make the transition to web work easier for developers already experienced with Windows forms and as a way to demonstrate the utility of the .NET class libraries. They represented a big improvement over original ASP -- which lent itself to truly hideous spaghetti code -- but as you have observed at this point it's a very dated paradigm. The assumption of doing all processing server-side between postbacks is antithetical to the kind of responsive web UI that has become popular in recent years.

You may want to research SignalR as a way to integrate more responsive design into a web forms project without abandoning its server-side focus.

By and large though, web forms are going the way of the dinosaur and any .NET stack dev shop will be well aware of this fact.
posted by trunk muffins at 9:57 AM on February 28, 2015 [3 favorites]

@trunk muffins has it. web forms are the past. there is value in learning them as it is not uncommon for legacy applications to have been built using the technology. most people are not using them for greenfield development.
posted by phil at 11:27 AM on February 28, 2015 [1 favorite]

I don't have a full perspective on the matter, but it would probably help you to keep in mind the concept of legacy enterprise applications.

Enterprise applications are often built for a captive user population. They access the applications using systems with a controlled configuration. That controlled configuration will include the which web browser.

This is all true of legacy enterprise applications, with the addition that the development technologies, target browser, etc, were all set years ago.

Some of the implications for you are: 1) If you learn Microsoft technologies, you'll probably find most of your work in enterprise development, often for "inward facing" applications. 2) Your influence on overall application architecture & technologies for new applications will be limited. 3) You will do a lot of work revising legacy applications. 4) The choice of technology and architecture for those legacy applications was made years ago, and probably differs from current best practices.

Even if the majority of webforms and based enterprise apps are slated for replacement (doubtful), it sounds like you are relatively junior, which means that you may end up dealing with essential changes to old apps while your co-workers work with newer, perhaps even better technologies.
posted by Good Brain at 11:30 AM on February 28, 2015 [2 favorites]

Nthing what was said above. WebForms is absolutely not the "best" way to architect an app, but if you ever have to maintain legacy apps, you'll more than likely run into it. It's a style that fits best with the old-style "everything is a separate page with a form you submit to do anything" paradigm. You can coax an acceptable architecture out of this (hint: your codebehinds should be as light as possible and just provide enough glue to hook into the rest of your architecture), but as you've observed, it doesn't do much to prevent bad architectural design, and it isn't great at handling more AJAXy-style apps.

I would imagine that most new development on would use MVC or the like instead.
posted by Aleyn at 12:08 PM on February 28, 2015 [1 favorite]

Web forms are pretty archaic IME.
posted by matildaben at 1:02 PM on February 28, 2015

I'll chime in and agree with everyone else. Web Forms were a solution for a problem that no longer exists. It almost always produces truly horrible non-semantic HTML that requires tremendous flips and twists to do anything with on the client side. Toss in a ridiculous viewstate object and the need to make heavy roundtrips to the server for virtually everything (even with partial postbacks), and you end up with a nightmare.

To my knowledge, the vast majority of new web development today is done with tools like you used in your first class. Personally, I right now I am living in Web API, Razor, jQuery, and Knockout.js (which could just as easily be Angular.js). I find it all to be much cleaner code (though not, of course, without its own pitfalls) and a much richer experience to the end user. But I also have a huge legacy project to maintain, so more often than I would like I find myself needing to work back in the Web Forms world. Such is the difference between the Platonic ideal and the real world.
posted by Lokheed at 2:58 PM on February 28, 2015

What everyone said above is true. Unfortunately, WebForms is still very heavily used in large enterprise and government. New projects are being written with it today, and there will be legacy WebForms projects that need support for a long time.

You're right to feel that everything you're seeing in the class is "wrong". I would file whatever you're learning away into a part of your brain knowing that it's obsolete, but that it could come in handy in your career, particularly if you work on the Microsoft stack.

I work for a software consultancy, and while 90% of our projects are using modern tech, every once in a while, we get a government client. My last project was a WebForms project. It was terrible, but knowing how it worked beforehand made the job much easier.
posted by alligatorman at 7:05 PM on February 28, 2015

The reason it feels wrong is because it is. Webforms is an attempt to add state to a stateless protocol. It was built with the best intentions, and seemed like a good idea at the time, but our understanding of how to use HTTP to deliver applications has progressed, and now it's obsolete. We'll probably be saying the same thing about RESTFUL services in 12 years...
posted by askmehow at 8:37 PM on February 28, 2015 [1 favorite]

Best answer: Webforms is an attempt to add state to a stateless protocol.

This. While a lot of answers here are valid,they are secondary to this - the root of the issue. This is the most insightful response here.

Almost everything *bad* you will ever see in web dev is a clumsy attempt to make 'water not wet' (to steal a phrase) it's an attempt to hide the fundamental underlying nature of http - it is stateless. and it is asynchronous.

Anything that tries to mask statelessness and asynchronicity will ultimately show diminishing usefulness moving beyond the most simple use cases.

That said, almost every web app IS the most simple use case: get stuff from a db (xml/json/whatev), do stuff to it (server-side business logic in .Net), structure it with html, style it with css, handle ui events with javascript. WebForms just coupled the associated elements (xml/.Net/html/css/javascript) into a drag and drop wysiwig element called a web control.

Now that you are sophisticated enough to require more efficiency and a clean separation of concerns, you're seeing the clumsiness of a web control.


ASP.Net is a lot more than Webforms. The web.config is an animal all it's own, that tailors how the web server (IIS) handles almost any aspect of the request and response. It is very, very flexible. Web services for IIS can be constructed with a variety of structures, WCF and HttpHandler are two. You could nearly build a career on knowing WCF, and all that it can enable. Then there's the WebAPI conduit.

My advice is to let the course work be an avenue into the really valuable topics.
posted by j_curiouser at 12:38 AM on March 1, 2015

btw, whether your average code monkey knows it or not, here is the reason javascript frameworks exploded in the last 10 years: It's sometimes sticky to synch state between the client and server side. So put as much BI as you can on *only* one side. The client-side won.

(tbh, i believed for the longest time that a super-thin client and a heavy server-side would have prevailed. The argument against was "message-size", and now look at every damn ajax call when you load a page. christ. it wasn't "message size", it was "state management".)

The model of "really dense SPAs plus stateless-ish server-side APIs" is a direct result of the script-kiddie inability to design statelessly, and coordinate synched-state across the gap.

Secondarily, the js frameworks pretty much let most dodge the hard parts of CSS and browser difference. Which, whatever, but jesus, can I please interview a guy who knows actual javascript.
posted by j_curiouser at 12:43 PM on March 1, 2015

« Older The cotton boyshort underwear that changed your...   |   Need an eye doctor in Manhattan/Brooklyn who deals... Newer »
This thread is closed to new comments.