mostlylucid

All about me... Sep 24

Reading Phil and ScottHa's 'Five things you didn't know about me' posts and started one of my own...but I only got to number two before I realized that the rest are either very illegal / potentially career ending so I stopped. Anyway I haven't posted here for a while and I wanted to give my reader an update on what's happenin' wit me...

Features...the name MS gives to 'stuff that's in the product', working away on some WebForms stuff. Some stuff has already made it to the world. I've worked on the ability to specify your own Ids for controls (client side) and currently looking at some Routing stuff, improving how our controls render their content as well as a hodge-podge of other stuff for ASP.NET 4.0.  In general I 'own' WebForms so all of my work revolves around improving the experience using this stuff.

Releases...if there's one thing the ASP.NET team does really well it's generate 'stuff', one of my responsibilities is how / where / when we release this 'stuff'; as an example we just released work from the ASP.NET QA team as well as 'Dynamic Language Support' updates. Doing this takes a lot of work for everyone involved, from the teams actually doing the work to my little part at the end where I make sure we're good to release stuff (legal, honest, useful) / do the physical release.

Process...probably my least favorite bit of my job, but a necessary one. All sorts of not very interesting stuff around navigating the bullshit that comes with working in a big company right through to dealing with incoming bugs / making sure dev's fixing them, PMs are making judgement calls and QA is testing the fixes. No-one likes doing it but my job's to buffer the team from all of the crap which inevitably goes along with what we do.

Community...one of my favorite bits of my job, working with groups like the ASP Insiders, events and generally looking after how the product team interacts with this stuff (and making sure we don't forget it!). Sounds easy but my (*heavily filtered) inbox gets >300 mails a day, about 10% of which are bang (!) mails...one of the hardest skills as a PM in MS is just managing your mail / keeping up with all the threads going on at any particular moment.

Personal life...pretty much dead. I made the decision after breaking up with my last girlfriend in March to take a year off and get things straight...5 years of continuous dating with a mean relationship length of ~2 months wasn't healthy.

So that's me...I'm a bit 'behind the scenes' on the team at the moment (well, compared to superstars like Haacked) but hey, I'm happy getting things done. I'll start speaking at conferences in the next few months...especially as my features will start getting more attention.

ViewState does not suck...part 1 Sep 09

I was trawling through new posts on the ASP.NET blog site and came across this one from Tess (who is someone I should probably know but don’t…). What I found interesting (as well as the post which is excellent) was the first comment:

  “When will MS simply drop the Viewstate completely?    This is a good example of a solution to a problem that shouldn't be a problem to begin with.

This got me to thinking, ViewState has gotten a really bad rap over the years (with notable exceptions). Let’s look at what ViewState actually is and why it might not be the villan it’s often painted out to be…

What is ViewState…at it’s simplest it’s a hidden field which contains data about the controls currently on the page. Really, that’s it…now it does this pretty cleverly, serializing a whole bunch of stuff into a Base64 encoded string (which can also be encrypted, validated etc…).

For those of us who wrote web apps back in the dark ages i.e., before ASP.NET, we remember the days where we had a bunch of hidden fields used to track changes in a page, and it was frankly a pain in the ass…it was far more transparent but a lot of grunt work just to track if a field’s value had changed / store some additional data in the page for use in postback. ViewState solves that problem pretty nicely actually.

So, what’s the problem people have? Two things:

1. people misuse it; it’s partly our fault and partly theirs.

From ‘Truly Understanding Viewstate’:

CASES OF MISUSE

a. Forcing a Default
b. Persisting static data
c. Persisting cheap data
d. Initializing child controls programmatically
e. Initializing dynamically created controls programmatically

Now, as I said it’s not entirely their fault…ViewState is enabled by default…if you bind a bunch of data to a DataBound Control then you’ll get a huge amount of ViewState serialized to and from the browser each time, it’s not that easy to figure out what having no ViewState will break / just enable it for certain controls and not others (which is what ControlState lets you do…just not for existing controls).
At it’s core the problem ViewState really has is that it’s a Leaky Abstraction; it’s ALMOST there but doesn’t quite hit the sweet spot nowadays…

So, how do you use ViewState correctly…what can you do to avoid the pitfalls?

Stay tuned!

John Lam’s Dev Kit Sep 08

Kind of a ‘tools’ list but a great post on what John uses on his machine…a few new ones I hadn’t seen which is always nice!

Know Issues / Breaking changes in ASP.NET 3.5 SP1 Aug 14

UPDATE 08/27: Found a couple of more changes 

We’re using this forum post to track our Breaking Changes / Known issues in the SP1 release. Initial text is below but please feel free to link to this forum post from any blogs etc...to track these changes.

I'll also keep this blog post updated with any changes...

With the release of ASP.NET in .NET 3.5 Service Pack 1 some breaking changes have been introduced. This post will be used to list those changes and any workarounds / fixes for these issues.

Issue:  Dynamic Data fails on Entity Framework data models that contain 1->0..1 and *->1 database relations
Reason:

Dynamic Data fails on Entity Framework data models that contain 1->0..1 and *->1 database relations with an error like "'System.Web.UI.WebControls.EntityDataSourceWrapper' does not contain a property with the name 'Orders.OrderID'". These types of relationships occur in many databases including Northwind and AdventureWorks. The error is caused by a naming mismatch that Dynamic Data has with the wrapper objects being returned by the EntityDataSource.
Workaround:
We have a temporary fix available at: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16367 which replaces the data model provider with one that names the properties correctly.

Issue: After installing .NET 3.5 SP1, a web site using a derived version of the UpdateProgress control may encounter the following exception: “A ProgressTemplate must be specified on UpdateProgress control with ID ‘id’.”

Reason:
In the .NET Framework 3.5, the UpdateProgress control enforced the requirement of a ProgressTemplate from it’s PreRender routine. A derived UpdateProgress control could subvert that requirement by overriding OnPreRender in the derived control, and avoiding calling base.OnPreRender. In the .NET Framework 3.5 SP1, the UpdateProgress control now uses CreateChildControls to instantiate the ProgressTemplate, causing the requirement to be enforced at a different point in the page life cycle, and preventing the OnPreRender technique from subverting the check.

Issue: Hidden files/folders inside App_Browsers are not ignored
Reason:
3.5SP1 does not “honor” the fact that _vti_cnf is Hidden… and it still tries to read it and parse the file inside that folder.. which results in this error.

Workaround:
At the moment the workaround is to simply delete _vti_cnf folder however we are still investigating a fix for this issue.

Issue:  The HtmlForm action attribute is now honored when defined in declarative markup.
Reason:
3.5 SP1 added a settable Action property to the HtmlForm type.  This new feature makes it much easier for developers to explicitly set the form’s action attribute for scenarios where a developer wants to use a different Url than the normal postback-generated Url.  However this change also means that if the action attribute has been set in an .aspx page’s declarative markup, ASP.NET will use the setting from the markup when rendering a <form /> element. 
Workaround:
Previous versions of ASP.NET always ignored the action attribute if it was present in the declarative markup for a <form /> element.  Developers should remove the action attribute from their declarative markup to return to the original behavior where ASP.NET renders the postback Url.
Example:
Before (the action attribute was ignored by ASP.NET as dead code):  <form name="form1" method="post" runat="server" action="test.aspx"></form>
3.5 SP1 (remove the action attribute to have ASP.NET render the postback Url):  <form name="form1" method="post" runat="server" ></form>

Issue: After installing .NET 3.5 SP1, a web site using pageBaseType now encounters the following compilation error: “Make sure that the class defined in this code file matches the 'inherits' attribute.”
Reason:
The behavior you are seeing is the original behavior of ASP.NET 2.0. When the .NET Framework 3.5 and Visual Studio 2008 were introduced, a bug was introduced that affected certain pageBaseType scenarios that unfortunately were not intended. It seems as if you might have run into one of these scenarios. In the .NET Framework 3.5 SP1, the bug was fixed and these scenarios no longer occur; pageBaseType again works the same as in ASP.NET 2.0, as requested by customers. Unfortunately, this means that customers who have relied on the unintended behavior that was introduced in the .NET Framework 3.5 will now encounter problems when they run their applications.

We are now evaluating creating a HotFix for these scenarios and providing workarounds for customers to help with this issue. 

Here are some details about the issue; we  will post a more detailed description soon. The mismatch is caused by the class in the code file not being assignable to the pageBaseType that is defined in the web.config file. The sequence that occurs is this:

- During code generation for a page (MyPage.aspx) in a Web site, ASP.NET creates a separate class from the class that is defined in the code-behind file source (MyPage.aspx.cs). The web.config file’s pageBaseType value can be used in cases where you want all pages to have certain properties. It applies to all pages, not just to pages that do not have code-behind files.

- If MyPage.aspx has a CodeFile attribute and therefore inherits from a class that is defined in MyPage.aspx.cs, the class defined in MyPage.aspx.cs must extend the pageBaseType class.

Workarounds:
1. If the pageBaseType class (for example, MyBasePage) is not needed for all pages, you can remove it from the web.config file, or;

2. Where pages do require the pageBaseType value, modify the classes in the code-behind files to extend the base type. In the filename.aspx.cs code-behind file, make sure that the class inherits from the pageBaseType that is specified in the web.config file (for example, public partial class CodeFileClass : MyBasePage instead of public partial class CodeFileClass : System.Web.UI.Page).

3. An alternative workaround will allow you to add the following attribute to your page directive:

CodeFileBaseClass="System.Web.UI.Page"

Find my inane babble on Twitter Aug 12

Keeping the noise down on the blog...you can find the non-lucid stuff on my Twitter feed (warning, cats and pancakes abound!)

Premature optimization and user perception...my pet project and CSS Sprites Jul 11

One of the themes I'm looking at for vNext of ASP.NET is the optimization of sites by reducing the number of server requests required for a single page.
A new classic in the area of improving the perceived performance of your sites by reducing the number of server roundtrips is Steven Sounders book 'High Performance Websites'. Steven's book is very small, very readable and probably the best book on anything to do with the web that I've read in years.
This book was a huge revelation for me...I spent most of my coding career writing the slickest, highest performing code I could...and frankly thinking about the structure of the actualy pages the user sees would've been a better use of my time in a lot of cases. As an example,, this was one of the last sites which I worked on as a full time developer...the code is about the best I ever created, the DB is optimized up the wazoo and I very nearly killed myself trying to make it 'perfect'...but for the hundreds of hours I spent sweating blood over the code you could now spend a couple of thousand dollars on a faster server and improve the performance even more...(even ignoring the fact that it's HUGELY overengineered...even has it's own MVC system and templating feature...hey, I was bored!)
As servers get faster and programming frameworks get more efficient, the amount of time your web server actually spends processing a page, doing a DB request and whatever else it has to do to generate HTML gets smaller and smaller; with better use of caching, AJAX and other techniques it's likely that you page actually returns it's total content to the user in milliseconds.... You can really only make minimal gains to 'preceived performance' in your sites by optimizing the dynamic code in your web application these days...(and this will likely only reduce over time)

Welcome to Moore's law

The fact is that for 99% of web pages the issue is no longer really about optimizing the amount of time your page takes to return HTML content to the user...it's what happens afterwards which leads to poor download performance.

The Problem

Websites nowadays have more and more separate elements in a single webpage, images, css, js files, flash content, videos etc...often the number of requests sent from single page can take MANY (as in several orders of magnitude) times longer than the bit we developers commonly fret about. As an example a few seconds ago I requested the CNN homepage, the actual page of HTML content loaded in 222ms, but the OTHER 153 requests for the rest of the stuff the page needed took a total of 4.65s.
One way to avoid a large number of these other requests is to combine requests for multiple objects together. In ASP.NET 3.5 SP1 we'll be shipping a feature called 'ASP.NET AJAX Script Combining', as the name suggests this feature combines multiple HTTP requests (in this case for the ASP.NET AJAX scripts) into a single request, potentially greatly reducing the number of roundtrips to the server.

Where is this going?

Well, a feature I've been playing with (and which I'm considering for ASP.NET vNext) is an ASP.NET CSS Sprite Control. Zack Owens has already posted about a technique for doing this in ASP.NET, but I wanted to increase the usability of generating these sprites; think using an ASP.NET image control and them magically being combined and output as part of a Sprite...
For those who don't know, CSS Sprites are essentially a technique which involves combining multiple images into one and using CSS to specify which one to show when they download. With this technique you both reduce the number of server requests as well as 'pre-loading' images on the fly (when's the last time you had an image rollover which seemed to stutter as it loaded the next image?).
Anyway, that's the idea; below is a some ASP.NET markup I'm playing with...this would resuly in a single PNG image being generated, along with a CSS definition for the sprite and for each 'image' to be displayed in the page.
This is still very much a work in progress and there's a ton of challenges around persisting the generated image in a scalable way etc...But well, I've been quiet of late so I thought I'd let you know what I'm playing with these days...

<html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<title></title>
<cs:SpriteManager runat="server" GroupName="DEFAULTGROUP" ImageFormat="png"></cs:SpriteManager>
</
head>
<
body>
<form id="form1" runat="server">
<cs:Sprite ID="Sprite" ReferenceId="Clock" runat="server" ImageUrl="~/icons/Clock.ico"/>
<cs:Sprite ID="Sprite1" ReferenceId="Contacts" runat="server" ImageUrl="~/icons/contacts 1.ico"/>
<cs:Sprite ID="Sprite2" ReferenceId="Alerts" runat="server" ImageUrl="~/icons/alerts.ico" />
<cs:
Sprite ID="Sprite3" ReferenceId="Download" runat="server" ImageUrl="~/icons/download.ico"/>
<cs:Sprite ID="Sprite4" ReferenceId="Desktop" runat="server" ImageUrl="~/icons/desktop.ico" />
</form>
</
body>
</
html>
 

 

 

 

Yes, yes I know! Jul 03

Blog, I have not abandoned you! I'm in a 'quiet' phase right now...be back soon (when work settles down a bit).

Ok, time to get serious... Jun 06

This site is increasing in subscriber numbers (literally doubled in a single day on the feedburner feed...not sure why!).I've also finally gotten my act together and got my old domain pointing back here again (only took me umm...a year). I guess it's time I got more serious abut this site again.
I've held off posting any more articles for a long time (read the blog, I suffer from a chronic lack of self confidence) but I guess it's time to get back on the bike. What I do want to post about is the more basic stuff, especially around how to best design and build an ASP.NET site. Oh, and I just realized...for those who don't know who the hell I am, I'm a Program Manager on the ASP.NET team at Microsoft...one of my responsibilities for vNext of ASP.NET is to 'own' (MS term...basically means 'be responsible')  the ASP.NET Page Framework. I was an ASP.NET developer for a long time before this and I'm passionate about our technology.
I think a theme of my posts / articles will increasingly be wading through all the new stuff we're coming out with all the time...I want to focus on the practical side of building software, e.g. LINQ is fantastic...but how does it fit into a security model / n-tier architecture, should you abandon Web Forms (a.k.a., the classic ASP.NET pages) and use MVC instead (for some things frankly, yes...), where does Dynamic Data fit in. I'm not an evangelist and I recognize that some platforms are just better than ours right now for a lot of applications.

So, a question...what would you like to see me write about...what don't you know that you wish you did, what do other people write about that you just don't grok (I still remember a long night just not getting the ASP.NET page lifecycle for example). Tell me, if I don't know I work in the right place to find out the answers to the questions!

Anniversaries make me sad...to the last best chance Jun 04

It's been ten years K...I know you still read this blog on occasion. This is for you...my last best chance...