I've been developing in ASP.Net for over 12 years and, though it was a bit of a learning curve to start, feel the webforms environment is, for most purposes, pretty good. When MVC came on the scene (first via 3rd parties such as Castle's, then through MS's own offering) everyone pretty much jumped ship declaring it the best thing since sliced bread. As I had a commitment to supporting a number of webforms applications, I didn't initially have any need to switch; and subsequently haven't found any compelling reason to do so. I've looked (briefly, admittedly) at MVC but felt it was a steep learning curve and didn't seem to offer any advantages, and have some actual disadvantages, to what I was used to.
I answered a question in Q+A today where I mentioned Webforms, and the need to decide whether to go webforms or MVC, and a subsequent comment was "I will not recommend webforms".
So I'm curious: what is it about MVC that makes it so much better than webforms? Is it simply that it's flavour of the month and commercial requirements for webforms developers has crashed? (plug: I have a requirement for a webforms maintenance developer ... message me for more details)
Is it that MVC is a lot "better", or do people feel webforms is actively "bad"?
My applications, using webforms, successfully separate business functionality from presentation issues (and indeed database/storage access from business objects). They implement multi-level inheritance, use custom controls to implement standard functionality, incorporate AJAX-based interactive features (not using Microsoft AJAX controls); and have proven to be flexible and extensible. Not yet found anything I can't do with Webforms.
Guess I must be the biggest opponent of WebForms here, even as far as calling it stupid.
What I didn't like?
Didn't like the way they tried to make it like WinForms, in which objects create HTML. So you create all these labels which are just span tags. Then when you go to port your HTML to another framework, you have to change all the objects back to actual HTML. As a negative effect, you never really master HTML or HTML5. If you stick with WebForms and not move forward, you stay stuck in that world of objects for years, never really moving forward to support phones, tablets and desktops.
I also got burned by the Ajax Control Toolkit. It worked great locally, but failed on long distance connections. The Partial Update control worked the same way. They added so much junk that was never really stable. Perhaps a WebForms app written for in-house use might be OK, but not for world wide production use. And then all of this stuff has to play nice with the Web Server such as IIS. It seems like WebForms with it's ViewState worked tightly with IIS server in order to post data back, and IIS server would have to keep track of every session out there.
Google just didn't play nice with WebForms. WebForms had a way of placing a script on the page, and using a weird URL for it's location that Google didn't like. I think it was a query-string added to the script name. Then Google complained about other elements I had no control over. And then the single use of the Form element, and having to work within that parameter or rule.
I could name probably 10 more things I didn't like about it.
I dumped WebForms and went MVC, and loved it. After the steep learning curve, I was able to reduce the time for new projects in half. Learned how to write very effective models and are close to my database designs. With views and razor, I was able to create new UI that where more user friendly, and much more fluid. Learned Gulp to package my CSS and compress files.
Then I dumped MVC and went .Net Core MVC loving it even more. Delivering blazing fast speeds but I still didn't care for Razor much. But my SEO tests were off the charts and Google loved it.
Last, I took the Angular jump, Angular wrapped in a .Net Core project. Figured out how to pack all my stuff like SASS, and compile it into a single project that runs in a Docker container. With this technology, I can now focus on providing a great user experience, with super efficient models and database designs, with blazing fast speeds. I spend very time writing code, in which most are just a few lines. I don't have to worry about slow connections any more.
Now I can develop in 1/16 the amount of time it took me in WinForms. My website below is version 298 at the moment. I have no regrets at all about leaving WebForms, even MVC as well. The WebPack train is running and lots of people are hopping on the train.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
Maybe I spoke too soon, one of my Docker MongoDB container crashed. First time in 7 months since I figured out how to use Docker that any container has crashed. 7 months uptime is not bad.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
Didn't like the way they tried to make it like WinForms,
That was pretty much the design principal. Many people's experience with writing "rich" MS apps was WinForms so they tried to move that stateful, event-driven methodology that people were used to onto the web so there wasn't as much of a learning curve.
you never really master HTML or HTML5
Because you don't write your own input tags? Input tags are probably 0.001% of html and html5. Like any technology, you can use it in different ways. Apart from the input tag issue you still have to do all the other html and css yourself. Also you don't have to use server controls, there is nothing stopping you using html only if that's your bag, it just means having to manage the state yourself.
Perhaps a WebForms app written for in-house use might be OK, but not for world wide production use
LOL, ok. Back in the day it was webforms or nothing so trust me, many world wide production apps were using webforms.
It seems like WebForms with it's ViewState worked tightly with IIS server in order to post data back, and IIS server would have to keep track of every session out there.
You don't seem to understand webforms very well. Of course it is tied to IIS. So? And ViewState is nothing to do with sessions, it's effectively a page-level session that IIS doesn't need to track, so kind of the opposite to what you said. Also Sessions remain in MVC too, they're not a webforms thing either.
Google just didn't play nice with WebForms
Again, simply not true. Google doesn't really care about your script tags.
And then the single use of the Form element
Gee, I wonder what I'm going to say here? You can use as many forms as you want with webforms.
I dumped WebForms and went MVC...Then I dumped MVC and went .Net Core MVC...Last, I took the Angular jump
It seems to me that you just think "the latest thing" is amazing whatever that is, and the second something new comes out the thing you used to love is now garbage. A lot of your complaints aren't really webforms related, they stem from how you choose to use it, and things like gulp tasks to bundle, sass etc might make "new" tech seem better, but again that is unrelated to webforms, you can still use all of that tech on webforms projects.
As for your website, it look me about 10 seconds to put it into a broken state....
Which seems like a good idea, until you see all of the developers who've never had to understand how it works "behind the scenes", who don't know which part of their code is running on the server, which part is running on the client, or even what the difference is between the two.
A problem that isn't helped by Visual Studio, where you develop and debug your server code in an interactive process on the same machine you use as the client.
Sometimes a learning curve is a good thing.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I agree, but we now have the advantage of hindsight. Back then they obviously thought different, and have since changed direction as web dev is now so ubiquitous there is nothing wrong with making it a completely separate discipline.
As for "why does my code work on my local machine but not after I've deployed" brigade, we had that on classic ASP, web forms and it still exists in MVC, you can still write server code where the html goes, but I think the fact that people are conditioned against writing code in the view means we see less "Why does Word not show when I click button, it works on my local machine" questions.
In the last years of me using WebForms, I did ditch the HTML objects for straight HTML and tried to normalize it as much as possible. I must admit that I have seen a few very good WebForm applications out there like Home - League Secretary. Not sure if the developer has made the switch to MVC yet.
I should of kept quiet on this subject and not said a thing about it. I might go back and delete my message. I can see all the WebForm proponents attacking my website, which is Ok for about a week so I can beef up the durability.
On my website crashing, I think I made a mistake in packing the that docker container and my controller API's were an older version that didn't match the client. The database basically just crashed and didn't bother to restart. I fixed it last night, and posted another build today. You have to refresh the browser to reload the new version.
The ViewState, could of swore I got that part right, or perhaps I read up on it with fake news. I can't remember my exact issue in detail about ViewState overall, but I can flash back to going through the Event Viewer and trying to fix every error with my WebForms E-Commerce site.
Advantages of server-side View State
The main advantage is that if a browser does not support a large encrypted file that is generated by the client-side View State then by the client-side View State we can handle it. As we know sometimes when we open an ASP web site in ASP.NET there will be some time corruption problem so it also minimizes the corruption problem. It also converts large client-side pages into a small client-side page because the View State data is stored at the server.
Disadvantages of Server-side View State
The main draw back is that the developer does not know how much space is taken by a View State on the server. If it takes a very large space there will be a problem. Another disadvantage is that server-side View State uses the server memory for the session object.
I sort of get frustrated with Asp.net post here and WebForm questions, like Richard said, most of the post don't know if their problem is on the client or server side. And all those GridView questions. I just got fed up with it and moved on to MVC.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
And with MVC people think everything has to be done with jQuery, that tables can only be created by jGrid (or whatever), they don't realise that Entity Framework is not a part of MVC and struggle with "using models without EF", they struggle getting their data from their view to their controllers because they don't understand model binding, they struggle using dropdown boxes because they don't understand the helper, they struggle with Url.Action because they don't understand the overloads, they're using json but don't understand the format or how to deserialise it, and so on.
I'm not saying webforms is perfect, or even good, I'm saying that all platforms have their quirks and issues and when you move from one to another you're simply moving from one set of common problems to another. Saying "this old tech is bad because of <these> problems" whilst completely ignoring all of the new problems that come with whatever is in fashion at the moment isn't giving a very fair or balanced view of the technologies in question. Criticise a tech all you want, as long as your criticisms are fair and accurate but don't give the impression that the tech de jour is going to solve all your problems and have no issues of its own.
I really feel that the concept of MVC has solved alot of the previous issues I had with WebForms. Whether the MVC is MVC, or Angular, Drupal, or something in PHP, I just like MVC better.
But to reiterate again, it's a shame that WebForms has sort of locked coders into a box, a certain way of thinking that seems to block new exploration into the parts that make up WebForms, to basically create HTML and use the HTTP protocol in general. Or to move forward to disassemble WebForms into it's actual components, and put it back together again as something better with other components.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
We've all been there with "demos"! Guaranteed way to highlight any bugs in your systems.
Re ViewState - the author of that snippet seems confused anyway as client-side viewstate does not involve "a large encrypted file ... client-side". Client-side view state is simply Base64-encoded data held in a hidden input field. (It can, optionally, also be encrypted). But in any case, arguments such as "the developer doesn't know how much space is taken" are erroneous; it's up to the developer to specify how much is being taken, because s/he should be actively coding, not just accepting defaults for everything. It's the developer's choice whether something is included in ViewState or not. If the developer doesn't have a pretty good understanding of what's in viewstate and why, then just bunging it all server side is not the answer!
I think F-ES Sitecore has covered a lot in his comments. I do understand what you're saying about Webforms sort of "hijacking" your HTML and can see that could have impacts in all sorts of areas. I came to ASP.Net from a Classic ASP background where I was very familiar with HTML, CSS et al and initially found ASP.Net confusing. It wraps certain input elements in spans etc which can play havoc with styling. I can imagine it would be doubly baffling if you use the visual designer. I work 100% in code and (once I'd twigged about the wrapping of radio buttons in spans) haven't really come across issues with its HTML generation.
ViewState can be a massive issue, but only if you leave it at default settings. You have a lot of control over what goes in viewstate and if it's not needed, don't put it in there. I've seen sites with viewstates extending to megabytes of data that only needed a couple of hundred, if that. And as F-ES Sitecore says, that's nothing to do with sessions. And of course, you can have multiple forms on a page. (E.g. I often have a login / reset password form, a search form, and a "main" form on just about every page).
Performance will be poor if you have a poorly designed application that doesn't make proper use of things like postbacks, viewstate, scripting etc. But that's true of any language / framework. I've found that when I take an old app I've written and re-write it, it performs better - regardless of the original and rewrite languages. That's not a language or framework issue, that's me having learnt "stuff" and building a better solution.
I guess in practice I only use the bits of Webforms that make my life easier or make the application more useable / reliable. I do roll a lot of my own code and make it very situation-specific, so it's lightweight and doesn't try to be all things to all people. That said, I've built up a library of techniques that I re-use time and again, and that makes development very fast in Webforms.
Really appreciate your input and comments; always interesting to get someone else's perspective on these things!
If you like AJAX then you will find it easier in MVC. WebForms wasn't designed for ajax, it was designed to be stateful across post-backs whereas ajax is stateful without the postback. While it is possible to use ajax with your webforms, it's just easier with MVC. The "template" nature of the razor views means you can use the same view and data to render html on page load that you can use to render html for an ajax call. The way MVC interprets urls using routing and data-bind also make ajax calls easier.
The other advantage is that it gives you better control over the html, which can also be a negative as it can take slightly more effort. Finally if you're into unit testing the fact that MVC "code behind" has greater layer separation it is far easier to implement unit testing at the controller and model level as there is no inherent dependence on the http layer.
"What's so bad about webforms?" Nothing, I say. The only thing you may want bear in mind is future maintainability by your project successors, if that is an issue. For whatever reasosn, WebForms are going out of favour, and finding (good) developers in years to come who can work with WebForms will only get harder.
But in and of themselves, WebForms are just fine. I still use them when I can get away with it. And I certainly don't have the issues with them that @jkirkerx does. (Who uses labels anyway? Use a Literal if you need to inject some HTML.)
As a negative effect, you never really master HTML or HTML5.
I gave up learning HTML/CSS years ago anyway - that's what front-end developers are for! It's their job to make sure thinsg render on different devices. I just use what they give me. I never use the designer features in Visual Studio.
I also got burned by the Ajax Control Toolkit.
I've never used the ACT. AJAX is simple enough to use with vanilla JS, or jQuery if you're using that anyway. I avoid "black-boxes" whenever possible. I like vanilla, and the KISS principle.
The trouble with so many out-of-the-box solutions to things is that they need to be all things to all people, catering for all scenarios. If you actaully sit an think about just what you need, it's usually only a tiny fraction of what some magic box offers, and you can have leaner code, with the added benefit of learning more, by writing your own code that does just and only what you want.
Nor have I expereienced any problems with Google, or IIS.
I'll have to take jkirkerx' word for it when he says "Now I can develop in 1/16 the amount of time it took me in WinForms" (I presume he means WebForms) but I can't say I've found that much difference, if indeed, any.
I like WebForms. I do accept that MVC, and now .NET Core, haven't come about for no reason, but there is a "horses for courses" aspect to all this. If you're a single developer on a relatively small-scale project (small business / charity / school, maybe) not too concerned about your code in 20 years... then there is no reason to give them up, if you're happy with it.
(On a separate but related note, I could make similar arguments for that other "black sheep" of the coding family: Visual Basic. Of course there are things you wouldn't use it for, but - horses for courses again - for smaller, simpler projects, why not? It's easy, quick, and quite up to the task - it does, after all, leverage the same .NET libraries under the hood.)
Thanks for your thoughts, A_Griffin. Seems you're a developer after my own heart! i.e. use the bits that work well for you, but don't over-engineer stuff and roll your own where it's a more effective / maintainable / robust solution.
Sadly I do also agree with you that finding skilled webforms developers is getting harder and harder (am currently looking for someone to take on support of a webforms application). Not only are new developers not learning it, but those that know it are increasingly reluctant to use it as, presumably, it detracts from building their MVC experience.
Finally I also agree about VB.Net. It's using the same framework as C# and, in the great majority of cases, provides the same functionality via a different syntax. I went through the process of converting a non-trivial VB.Net application to C# and an automated converter was able to do 99% of the changes for me, which suggests to me that the two languages are virtually equivalent. Sure, C# may encourage certain good coding habits, but a badly-written C# program is always going to be worse than a well-written VB one.
Your arguments regarding WebForms are quite sound and I have written papers on the matter over the years.
As one commenter posted, the WebForms design was to make its development similar to WinForms, which at the time was where most Microsoft developers would have been moving from, or form Classic ASP, which was more difficult to provide necessary functionality.
There is absolutely no business advantage to the use of MVC over WebForms. In response to the commenter who has found MVC far superior to develop with I can only assume he has never worked on a massively, complex, MVC project as I did back in 2010 using MVC 2.0 (it was one of the largest MVC projects in the US at the time).
Such projects place one in a position to see all the failings or rather the impediments of using the MVC paradigm, which is the massive, additional detail that WebForms helped to reduce.
For all the complaints regarding WebForms, I can list just as many for MVC. However, one can design well functioning MVC applications just as one can do the same with WebForms. It is all how it is done.
Despite this, MVC will take a much larger learning curve to master well and the supposed desire or preference for more control over the development of components to an MVC application is more or less merely a mirage that MVC proponents like to tout. Just like the comments that one can develop faster with MVC than in WebForms. If one is finding this in their daily development endeavors then they are not doing anything dramatically complex.
However, the underlying reason for the move from WebForms to MVC was basically a result of a "herd mentality". Everyone was doing it so most felt they had to get on the band wagon.
At the time this move began, which was around 2010 or so, there was growing influx of younger technicians mixed with a strengthening in the Open Source Movement, which combined to push the greater complexity of MVC over the more simplistic WebForms paradigm whereby such complexity had been early drawback to the Open Source Movement itself. The other elixir in this mix was the rapid growth of stupid-devices that everyone believed (and still do) was the Second Coming in technology.
To be sure, WebForms did have its drawbacks technically. However, Microsoft continued to refine it over the next several years, where it could easily match the capabilities of MVC where WebForms had originally been weakest. However, by then, the damage to the WebForms environment had already been done by the technical community itself.
If you do the in depth research as I have done regarding the many reasons for moving from WebForms to MVC you will not find a single, solid technical reason for doing so except for the fact that it is what one does now. Business users really don't care about any of the reasons that technicians give about the superiority of MVC. All they care about6 is if the applications they have to use work well.
Though I retired several years ago, I still do development. However, when considering expanding a current commercial product into a larger format that could be used by small companies instead of just by individuals, it didn't take me much time to make the decision to stay away from web development and simply go in the direction of a client-server model.
I can make this claim just by observing the continuing and increasing data breaches against corporations (who still continue to pay lip service to security while using insecure techniques to develop their applications) and the increasingly poor quality of many public facing web sites.
It doesn't take a rocket scientist to see that web development has been going downhill since 2010 and even professional technicians have weighed in on this trend here on The Code Project itself...
Sr. Software Engineer
Black Falcon Software, Inc.
Steve, many thanks for the insights you give from someone who's worked on non-trivial applications in both technologies. Your comments confirm what I'd suspected. I work with lots of smaller clients - in most cases completely non-technical - and though I make it clear in my proposals I'll be using WebForms technology, this has never been an issue and the customers are happy with the end result.
My feeling is that the rush of new frameworks and languages has slowed down a little in the past couple of years. Some technologies are beginning to mature and recognition is spreading that the way we approached development a few years ago (just grab components off the freeware shelf, together with whatever framework dependencies they dragged with them, and throw it all together) won't cut the mustard.
You are part of a growing chorus of professional technicians who are starting to realize that increased complexity does not always translate into increased capabilities or even ease-of-use.
Most of the original complaints regarding WebForms were legitimate. However, they were primarily targeted at the internals of the environment, which in many cases had work-arounds so one could avoid their pitfalls. However, as I had mentioned, Microsoft worked to improve these internals and did a rather good job of it.
Had the community not simply walked away from the WebForms environment, it would have received more refinements.
Of course we have the Microsoft issue where the company continuously "throws the baby out with the bathwater" when introducing new refinements and\or products. This corporate problem did not help their case to maintain WebForms as a viable development environment.
Doing so has changed the orientation from server-side supported applications back the "fat client" model, which is the very thing that was fought against in the late 1990s and early to mid 2000s. Professionals that time all agreed that the "fat client" model was unwieldy and presented more issues than it was worth. Thus, we stuck with the "thin client" model, which I still adhere to.
When MVC emerged, many professionals used it as an excuse to blame the inefficiencies of WebForms as an environment that was not workable while laying the blame on its internal model (web-page\code-behind) as the basis for many poorly written applications. However, this aspect of WebForms was never the fault of the design but the result of poor development techniques. The Code-Behind component side of things was only intended to be a dispatcher while also handling immediate display constructs. Nonetheless, many developers merely stuck a whole lot of code in these server-side modules making WebForms look more like a whale than it actually was.
Despite all of the crowing regarding MVC, I have never found a single analysis of the performance aspects of it against WebForms with the exception of a single professional's curiosity who bench-marked an in-house application in both environments. He found that after 100 concurrent users in either application there was absolutely no difference in performance between the WebForms and MVC applications.
To me, WebForms was and still is the zenith of web development on the current Internet topologies. Considering that the Internet was never designed to support what is being thrown over it today, WebForms was a very successful implementation to make such development a far easier and more approachable technology when compared to anything MVC has to offer.
Sr. Software Engineer
Black Falcon Software, Inc.
Error:'D:\test_data\sample_bulk_upload_File.xls' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides
path = TextBox3.Text
s1 = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" + path + ";Extended Properties=""Excel 8.0;HDR=YES;"""
Dim OLEcon As OleDb.OleDbConnection = New OleDb.OleDbConnection(s1)
Dim OLEcmd As New OleDb.OleDbCommand
Dim OLEda As New OleDb.OleDbDataAdapter
Dim OLEdt As New DataTable
Dim sql As String
Dim resul As Boolean
.Connection = OLEcon
.CommandText = "Select * from [data1$]"
OLEda.SelectCommand = OLEcmd
For Each r As DataRow In OLEdt.Rows
The path D:\test_data\sample_bulk_upload_File.xls is valid on your development machine, and becomes invalid once deployed to the production server. You need to provide a path which is valid in the context of executing environment.
The best solution for this kind of issue is to avoid hard-coding the path. Better include it in a configuration file, of which you can have separate versions for development and production environments.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
Last Visit: 31-Dec-99 19:00 Last Update: 27-Nov-22 18:25