Fun with IIS http compression

Ah the wonderful world of System Administration. My first task of the day was test a site using HTTP compression. So I followed the instructions to turn on http compression in IIS6. What a wonderful mix of UI, XML file fiddling and vbs scripts that was…<good grief>. Finally I managed to start seeing the production of compressed files in IIS’ folder. "Hurray, it’s working", I foolishly thought. My specific test site just kept failing, nothing would render a page. So, like all "good" developers I set compression to global, i.e. all the sites and went to the default iisstart.htm to see if that was ok. Sure enough the compressed version of it appeared in the IIS folders and IE7 rendered it without any fuss. "Hurray, it’s working"…I foolishly thought. Firefox 3 just stubbonly says, ‘The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression’. However, it looks like that happening on a number of sites with FF3. So I tried Safari. What a joke, doesn’t seem to want to see the page at all, moaning about a domain error. Opera 9.5, to the rescue, it acutally rendered both my test page and the iisstart.htm. Well I say rendered, it just showed me the contents of compressed file, i.e. it hasn’t bothered to uncompress it! Chocolate fire-guard anyone? So time to admit defeat and go off to the TechNet forum. Oh it just keeps giving. I tried to login, complained that my account hasn’t been verifyed, even though I used it about 1 year ago now. So I thought I’d register again. Every character I typed threw up a javascript error with IE asking if I wanted to debug it. What a waste of time.
 
So all in all my first professional brush with IIS6 compression has been…less than satisfactory.
 
[Edit]
I’ve since tried download ZipEnable from Port80 which didn’t help, but then I copied the settings from http://www.codinghorror.com/blog/archives/000059.html and finally it started to work, all the browsers too.
 
 
 
 

More Microsoft AJAX views

I do have a tendancy to get annoyed when I think about Microsoft’s web offerings of ASP.NET and more recently their AJAX libraries. I’ve had a little rant about it before but I thought Adam Kahtava has written a good post on the AJAX side of things here, The ASP.NET AJAX Framework is for DUMMIES!
 
I’m not sure I’d go so far as to say the library itself is bad, IMO it has a lot in common with Prototype, but I certainly feel the pain of pandering after the server controls. Although there are a number of "pure" AJAX libraries to choose from some also have projects/extensions to help with server controls, e.g. http://www.codeplex.com/YuiDotNet, so maybe you can move to another library without leaving the server controls behind.
 
 

Fun with Microsoft AJAX UpdatePanel

Recently I’ve been asked to look into a problem where code running in an UpdatePanel was generating the following error;

sys.webforms.pagerequestmanagerparsererrorexception: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.write(), response filters, httpmodules, or server trace is enabled.
Details : Error parsing near ‘<!DOCTYPE html PUBLI’.

So what’s happening here? The UpdatePanel mechanism works by requesting the whole aspx page from the server and then using black-boxed JavaScript code to grab the changes that the UpdatePanel area represents in order to update the browser accordingly. This requires that the UpdatePanel’s client side script gets exactly the page it was expecting. Any changes, such as using document.write or traces will upset this requirement and you get this error. Another way of upsetting this apple cart is if the server decides to totally change the page, i.e. the server issues a Server.Transfer. Server transfer is a very seductive technique because it doesn’t require bouncing any requests off the client, the server simply changes (transfers) from rendering page A to rendering page B. However, when we look back at the UpdatePanels requirements for having the same page then it quickly becomes obvious that it’s going to get upset again! So that’s it, I now know how to avoid upsetting the UpdatePanel, well so you’d think. In the particular case I was asked to look at the server was issuing a page redirect. At first thought you’d think, "aha, it must be the page the UpdatePanel expects", but no. The UpdatePanel is savvy enough to realise that a 303 redirect isn’t really meant for it, so it passes it to it’s container, i.e. normally the browser window. So although you can’t use the "page moved" technique to change the service end-point at least the server code can issue redirects without having to know if the client is a browser or an UpdatePanel. So why am I seeing the error still? Hmm, I’m still not sure. Something somewhere is consuming the 303 redirect and then correctly requesting the page B from the Server. Page B is then consumed by the UpdatePanel, therefore behaving like a Server.Transfer and hence I see the error. Unfortunately the page structure is complex, with a number of dynamically created controls and iframes so something in that goo is consuming the 303 before the UpdatePanel. So what’s a developer to do? Well handle the error that’s what 😉 Rather than write lots of nasty code to dynamically rewrite the UpdatePanel’s JavaScript you can use the following, Sys.WebForms.PageRequestManager endRequest Event

In my case I chose to examine the error condition, if there’s one the change the window.location and redirect the client to an error page. You can examine the args to see exactly what was returned to make more interesting decisions about how to process the error. Also you should mark the error has handled (=true) if you don’t want the UpdatePanel to carry on raising browser errors.

Problems upgrading Silverlight Beta 2 project

Finally had to upgrade one of our development machines to Silverlight 2 Beta 2, and boy did Blend not like it. After installing Beta 2 the project opened in Blend but crashed when you tried to build the project. So uninstalled Blend, installed the latest version and tried again. This time the browser launched but there was an error (from javascript) and an empty page. After some messing around I finally threw my hands in the air and just created a brand new project and copied the assets over. That didn’t work either. The new project had a different name and after trying seemingly everything (I’m not a Blend person) I gave up and created yet another project but this time was careful to give it exactly the same name. Finally the project runs. I thought we could have at least had an upgrade old project, oh well that’s the life of a beta user I guess.
 

Implementation of missing combo control/drop down control

I found Michael Sync blog whilst looking for a Silverlight combo box control, I’ve not tried it yet but it looks promising since it contains the source too (never take a control without the source code!).

A couple of things that don’t (currently) work in Silverlight

I’ve just tried a couple of ‘tricks’ in Silverlight to avoid writing "code-behind" but both failed.

Using XAML triggers:
One mechanism that should work in the final version is the ability to create XAML that responds to an even and can trigger something else, such as a storyboard. This is especially useful for Designers who want to test their designs/animations without having to write procedural code. The XAML is "supported" but simply doesn’t work, you get odd messages about values been out of range. This is the idea anyway…

<Rectangle.Triggers>

<EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">

<BeginStoryboard Storyboard="{StaticResouce mystory}"/>

</EventTrigger>

</Rectangle.Triggers>

However, it’s not all bad news, you can use the above technique if you embed the stroyboard rather than using the static resource. However, this isn’t good for a Designer using Blend as currently blend "loses" the storyboard…you can’t win 😉

Embedding code into XAML:
XAML has a special inline code element, <x:Code> that you place procedural code into it. Ok so you need to write the event handler but that’s pretty close to boiler plate code so easy to copy. Plus you don’t have to leave Blend to write it. However, when I tried it Silverlight just didn’t like it and wouldn’t run the page let alone the code.
 

One transaction performance barrier broken

One of my biggest bugbears with .net transactions is that for all but the simplest of cases your transaction will be promoted from a light-weight transaction to a full-blown DTC transaction even when the only database you talk to was SQL Server 2005. However Florin Lazar (a must read for those interested in transactions) has blogged about some welcome improvements to SQL 2008 that mean we can finally go all light-weight…for once that phrase is a good thing (well apart from fast cars, planes, moving house…)!
 

Silverlight full screen, now with limited keyboard support

Since I blogged about the difficulties of not having keyboard support in Silverlight when you’ve gone full-screen I thought I’d better say that with the latest release of Silverlight 2 we can now access the basic keyboard navigation, e.g. tab, arrow keys, space, etc. It’s better than nothing I suppose. I think I’d prefer some form of keyboard overlay that lights up as you type, so for those paranoid about password sniffing attacks the user could see that the application is catching the keyboard messages regardless of the visual state of underlying application. Somehow I doubt that will happen.
 

getElementById gotcha

I was looking, and I can’t stress this enough, at someone else’s HTML/JavaScript. The code looked something like;

<a onMouseOver="elementid.className=’New’" />…<img id="ElementId" src=…>…<div id="elementid">…

so I was asked to find out why this wasn’t working in a number of browsers. Well the first thing I spotted was the non-standard way of accessing the className in OnMouseOver. So I changed it to document.getElementId(‘elementid’).className=’New’; No errors but the style change (which was working in IE with the above code) stopped working in IE. It took a fair bit of head scratching but as you can probably tell by the HTML i’ve added but yet to talk about the problem was the img tag. In the first example of directly setting the className the call is case-sensitive and correctly alters the style of the  DIV. However, and this was a surprise to me, getElementById is case-insensitive and was returning the img tag rather than the DIV! Therefore, and it comes as no real surprise, don’t rely on the case when creating unique Ids.

New graphics card

My ageing 6800GT was starting to struggle so I decided it was about time to upgrade. The current choices of cards are bewildering but I finally decided upon a 8800GT cause the price mark is pretty cheap and they provide a decent frame-rate given the fairly old system it’s going into. However, there are two problems (for me) with the 8800GT; 1. Noisy 2. Pumps heat into the inside of the box. So after a bit of a search I discovered the Gainward GeForce Bliss 8800GT 512MB Golden Sample. It’s got a bit of factory overclocking (nice), it’s a dual slot (so pumps heat outside of the box) which is fine for me since I only have one 16x slot, and it’s got it’s own cooler which makes it very quiet. Installing it was pretty easy although the dual face plate was a little deeper than normal which caused it to hit my cases face-plate holder. Luckily as I was scratch my head wondering how to solve the problem it slipped into place. So how does it run?
Under Vista 32-bit it didn’t realise what the card was until I downloaded the latest nVidia drivers, restarted and all was fine. In fact the same thing happened on my XP boot as well. So the installation was pretty easy. Performance? Well I’m not one that’s bothered about playing things with every setting switched so UT2008 and COD4 looked better, UT had more fun bits enabled and was far less Lego like. The big difference was with Clive Barker’s Jericho which was an absolute one legged dog on the 6800 but fine on 8800, in fact there is so much graphic effects going on that I found it difficult to actually see what was going on!

So for £110 I can only recommend it for someone wanting to upgrade their medium gaming rig. Plus it comes with Lara Croft Anniversary…although she normally makes my blood boil…to quote Spaced, "can’t shoot straight you big t*tted b*tch".

Kick it! | DZone it! | del.icio.us