View Single Post
  #2 (permalink)  
Old February 7th, 2012, 04:20 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi there,

I come from a Classic ASP background and I hear what you're saying. However, ever since I made the switch to .NET about 10 years ago, I never started a new project in Classic ASP anymore (although I have been supporting and updating existing Classic ASP apps).

I think part of your frustration (which is understandable) comes from inexperience with the product and the framework. Use some of the new features, and you'll appreciate how it works. Let me address some of your concerns in the remainder of this post, with an alternate direction you could take at the end. For the record: all of this post deals with ASP.NET Web Forms as that's what you seem to be working with right now. The alternate direction talks about a different ASP.NET solution: ASP.NET MVC.

ASP code seemed to be everywhere on google, but now everything has been
taken over by .net or something else. Its like somebody has put ASP classic
in a cupboard and we're not allowed to talk about it! The NGs seem to have
taken a battering as well.
Yes, that's true. I think first of all, more and more people are doing ASP.NET and thus have the need for good NG support. Also, most of the Classic ASP stuff has already been discussed in the past. Since there are no new developments, there's not much new stuff to talk about and discuss. However, you'll find plenty of examples and NGs still. On Google, "classic asp example" returns 2.6 million hits (granted, example does over 40 million).

Working a the code level enabled us to make our code text very lean (MS Word HTML what a joke!) and we could use numerous techonolgies (eg CSS, ASP, DOM, Javascript, ASP, COM, etc) in our pages without any constraints but our brains.
You're certainly not alone. Many others have said the same: limited control over the HTML that is rendered, page bloat, massive ViewState data and more. Most of it is true out of the box, but you also have control over many steps in the process. Use a GridView and turn on ViewState and you could end up with megabytes of ViewState. Use a ListView instead and make some intelligent decisions on how to set up up and approach your data and it can be as clean as Classic ASP with faster performance. So, it all depends. Yes, ASP.NET easily enables you to create a big mess at run-time that's worse than the spaghetti mess that Classic ASP can be at the server. But just as you can write clean, optimized and maintainable sites in Classic ASP, so can you write well behaving and performing ASP.NET web sites.

The master pages thing is a classic as it talks about making common 'chunks'
for your pages, but the implementation (code wise) is way more confusing
than the simple include file method that we all used and we could stick
these includes any where we want and as many as we want.
Master Pages (and User Controls for non-structural reusable blocks) are *way* better than includes. They enable a consistent and type safe design. Also, rather than just centralizing look and feel they also enable you to define logic and enable you to program them at run-time. Master Pages are a feature I have been wanting for a long time (they didn't exist in the early versions of ASP.NET) and you'll appreciate them if you better understand how they work.

Is it actually possible to code rather than drag and drop objects
like Visual Studio?
Absolutely. In Visual Studio 2010 you can opt for a "code only" model to disable all "design time" features. More details can be found here:

This means you'll need to manually hook up events (such as a Button's Click event) in the Code Behind manually but that seems to fit the code model quite nicely. In the next version of Visual Studio, the code only mode is expanded and enables you to bind event handlers from the Code Editor without manually typing all the code needed:

I always did my ASP > DB stuff in code as you could do
all of this in very little lines of code and do whatever you want, but there
doesn't seem to be any 'raw coding' books out there. Everything is through
the GUI, but then the forums all post code solutions. Where are people
finding these source code examples??
There are dedicated books on ADO.NET (the successor to "classic" ADO) such as this one: They show you how to do raw coding. In addition, you may find my series on N-Layer design interesting as they cover a lot of hand coding as well:

However, you may also want to look at the Entity Framework Code First. EF is an ORM that handles a lot of database interaction for you. The "Code First" flavor lets you create your own classes and code which are then handled by the data access framework, giving you great control over the process. This way you can focus on the business requirements more than on boring stuff such as defining parameter sizes, without giving up control.

So, to summarize, yes, ASP.NET Web Forms can be a daunting framework to get started with. It can generate a mess at run-time, and it may make you feel you lose control when working with the visual designers. However, all of this is a choice. You don't have to create a mess when you know what you're doing. You don't have to use the visual designers if you prefer to handcode. And you don't have to use the built-in SqlDataSource if you prefer hand coding (although I would still recommend to use the ObjectDataSource control to target your own code). So, all of this is a choice.

However, as I said earlier, you are certainly not alone. Microsoft has been hearing this for years, ever since they released the first version of ASP.NET back in the days. In response to that, they released ASP.NET MVC (Model View Controller). MVC takes away all these disadvantages, giving you a code only experience, with full control over markup and other run-time behavior. MVC is really popular today as it addresses many of your concerns about AP.NET Web Forms.

If you want to find out more about MVC, take a look here:

If you want to use Web Forms instead, you can take a look here:

Additionally, you may want to take a look at my Beginning ASP.NET 4 in C# and VB book that deals with Web Forms exclusively:

You may want to read more about the Web Forms versus MVC debate here:

The good thing is: these frameworks "learn" from each other, giving you features that previously only existed in the other. As Scott Hanselman put it:

One other thing I wanted to say. It's becoming clearer to me that it's less about WebForms or MVC or WCF WebAPI Services or OData or IHttpHandlers or SingalR and more about ASP.NET. I used to call mix-and-match apps "hybrid" applications, but now I'm realizing they are just ASP.NET applications. I'll use whatever LEGO piece(s) I want and you should also.
I think I spend as much time with MVC as I do with Web Forms. And I like both of them.

Sorry for the rant. I'd prefer to stay ASP classic, but it seems like
everybody is putting it in the cupboard and moving on.
Sorry for the long reply, but that's what you get when you post a long rant.... ;-)

Hope this clears some of your doubts, but feel free to post follow up questions....


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote