ASP.NET First Thoughts

I'd announced a few weeks back that I was taking a role as a .NET desktop developer, but I've found that I'm actually going to be doing a good bit of ASP.NET web development as well (w00t!). As such, I've shifted gears a bit and dropped my studies of WPF for ASP.NET, and although I'm certainly not an expert yet, I thought I'd share my first thoughts.

Unlike ColdFusion which is a combined language of CFML tags and CFScript, ASP.NET is broken into ASP pages, and "code-behind" compiled classes created using C#, VB, or any of the other .NET languages. I'm developing ASP.NET with C#, which I find to be a very interesting language in its own right (and deserving of its own post, which will come later), so if there are differences between how things are done with a VB code-behind and a C# one, I'm not aware of them at this point. Being backed by C# and the .NET libraries are a great starting point to a web platform, so I was excited to dig in; so far I find ASP.NET to be a bit of a mixed bag.

Master Pages

One thing I'm liking so far is the concept of a "Master" page, that establishes a wrapper for site content. It functions similarly to a layout in Rails or a file that defined a header and footer and then included the target page in CFML. What I like about how ASP.NET handles this setup is that a single master page can have multiple dynamic content areas, and a single page can define the content for multiple areas in its master page. For example, a master page might look like this:

<%@ Master Language="VB" CodeFile="Site.master.vb" Inherits="Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
<title>Untitled Page</title>
<asp:ContentPlaceHolder id="head" runat="server">
<form id="form1" runat="server">
<div class="main">
<asp:ContentPlaceHolder id="MainContent" runat="server">

<div class="LeftColumnContent">
<asp:ContentPlaceHolder id="QuickLoginUI" runat="server">

<asp:ContentPlaceHolder id="LeftColumnContent" runat="server">


And a given page might look like this:

<%@ Page Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
Sign In</h2>
<asp:Login ID="Login1" runat="server" TitleText="">

<asp:Content ID="Content3" ContentPlaceHolderID="QuickLoginUI" Runat="Server">

<asp:Content ID="Content4" ContentPlaceHolderID="LeftColumnContent" Runat="Server">
<h3>Sign In Tasks</h3>
<li>Create a New Account</li>
<li>Recover Forgotten Password</li>
<p>TODO: Turn the above text into links...</p>

The basic idea is that the content of each tag is plugged into the matching tag. If you wanted to understand it in ColdFusion terms, its kind of like wrapping all of your page content in tags and then including a page that output'ed the contents of each of those sections where it needed to go.

Custom Request Handlers

Another nice feature in ASP.NET is the ability to create your own HTTP request handler, but I quickly found that it wasn't as interesting as I'd first thought.. ASP.NET comes with a couple of built in handlers that handle ASP.NET pages (.aspx), Web Services (.asmx), and simple HTML page content, but you can easily write your own to handle other HTTP requests. The problem is that you still have to explicitly tell IIS to route files with certain extensions to ASP.NET, when then does a look up against a table to find the handler... I could do that in CF if I wanted to, I just don't want to have to touch IIS for for my solutions, since on hosted environments, I don't have access to that level of IIS manipulation. This seems like a feature that I'd like to see in action before I pass final judgement, but it seems limited as is.

Drag and Drop Elements

This is more of a function of Visual Studio than of ASP.NET itself, but the ability to drag-and-drop components on to a page to create a fairly rich feature set with minimal work is very attractive. Drag a data grid onto the page, click a few buttons, and the grid is set up. The code is a little more bulky than ColdFusion's >cfgrid<, but you don't have to setup a seperate file to handle it:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"
DataSourceID="SqlDataSource1" ShowFooter="true" AllowPaging="True" AllowSorting="True" OnRowCommand="GridView1_RowCommand">


<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"/>
<asp:TemplateField HeaderText="CategoryID" InsertVisible="False" SortExpression="CategoryID">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("CategoryID") %>'></asp:Label>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label>
<asp:TemplateField HeaderText="CategoryName" SortExpression="CategoryName">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryName") %>'></asp:TextBox>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label>
<asp:TextBox ID="CategoryNameTextBox" Runat="server"></asp:TextBox>
<asp:TemplateField HeaderText="Description" SortExpression="Description">
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
<asp:TextBox ID="DescriptionTextBox" Runat="server"></asp:TextBox>
<asp:linkbutton id="btnNew" runat="server" commandname="New" text="New" />


Change some flags and you can do in-line editing of the grid, change some more and you can have pagination, and all kinds of other features. Unfortunately there is a trade off for this kind of power, and that brings me to my last point.

Loss of Control

While ASP.NET does give me a very nice suite of components that can be used to boot-strap a project in no time, I keep finding myself wincing when I look at the source that ASP.NET spits out for these things. For that matter, I can't really stand the source that ASP.NET spits out just to function. ASP.NET tramples on many of my expectations about web design, and does so in ways that I find questionable at best. For instance, rather than having a page with multiple forms that go to different locations, ASP.NET wraps all of your content in one giant form, and then attaches event handlers to certain buttons to determine what happens when you click a button. Behind the scenes it works fine, being completely invisible to the user, but from the development side, it confuses me a bit. Also, ASP.NET makes up IDs for its elements based on their location in the document and a number of other features, so most of the concepts you have about doing Javascript programing based on ID seem to get thrown out of the window. Finally, the HTML it produces is just ugly, with lots of stuff indented funny or not at all. Its not going to impact the program, but its ugly.

All of these things are aspects of what I feel is a bigger problem, and that is loss of control. I hate it when a platform thinks it knows better than me, without giving me a clear way of getting around it. If its a client-side tag, I can virtually guarantee that my JS code is going to beat their JS code for efficiency and simplicity any day of the week. If its generating server-side code, what happens when I want to override something? I don't use the >cflayout< tags in CF8+ for the same reason; I can do it better, and I'll be able to control it if I need to change something. This is something I see as being kind of a universal problem, rather than an ASP.NET problem; as web platforms start to transition from language only to language + framework you're going to see more of this kind of thing, and I question its real value. As for ASP.NET's implementation, I'll have to wait and see. I can't really judge the framework without more experience, but considering the shop where I work has told me that they've hand to throw out a lot of ASP.NET's built in features and write there own doesn't bode well.


I've got some big reservations with this languageframework, but I'm still waiting to see how it shakes out. Right now I'm looking at it and not seeing anything that I couldn't do as simply or more simply with another language, but I have to believe that I'll see some nice performance gains with heavy-lifting processes since I have the benefits of a fully OO language. That said, I'm still not convinced that an OO centric way of looking at the web really jives with other web technologies, and/or that ASP.NET's view of how OO should work out is the best.

Does any one have have other perspectives about ASP.NET that they'd like to share?


Comments (Comment Moderation is enabled. Your comment will not appear until approved.)

Mike Harman's Gravatar Good post Jon! I was in the same boat a year ago and, like you, am also loving it.
Andy Sandefer's Gravatar I'm a certified CF developer who is learning C# with the intent on using it for any of my clients that want ASP.NET powered apps. I'm only a week or 2 into it but what from what I've seen thus far it is a great platform for building desktop (client/server) applications - and not so great for building RIA's. Just my opinion, maybe I'll have a different take on this after I get some more experience but I just feel like I'm giving up a great deal of productivity and control. However, I do love the IDE and building desktop apps with it for sure.
Jon Hartmann's Gravatar @Andy

Yeah, I'm feeling the same way. WPF on top of .NET is a nice way to build stuff for the desktop, but ASP.NET isn't wowing me on the web-front. Check back when you've learned more and maybe we can compare notes :)
Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me.

Post a job. Find one.

Interested in becoming a sponsor? Contact me.