ASP.NET Web Forms: This all feels wrong to me!
-
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?
-
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.
coreywilliam at Ask.Metafilter.Com Visit the source
Other answers
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 http://signalr.net/ 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.
trunk muffins
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 ASP.net 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.
Good Brain
@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.
phil
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 ASP.net would use ASP.net MVC or the like instead.
Aleyn
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...
askmehow
Web forms are pretty archaic IME.
matildaben
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.
Lokheed
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.
alligatorman
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.
j_curiouser
Related Q & A:
- How can I allow user to create posts in website using ASP.NET?Best solution by Programmers
- How to Undo previous action in asp.net?Best solution by forums.asp.net
- How to Play Audio files in ASP.NET?Best solution by Stack Overflow
- Why is my asp.net menu not showing properly?Best solution by Stack Overflow
- What would be the best book to Help me learn web design in C# and asp.net?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.