<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Just a Coder &#187; Bugs</title>
	<atom:link href="http://www.nickfitz.co.uk/categories/bugs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nickfitz.co.uk</link>
	<description>The occasional online observations of Nick Fitzsimons</description>
	<lastBuildDate>Sun, 08 Jan 2012 02:09:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>More On ASP.NET&#8217;s Broken Error Handling</title>
		<link>http://www.nickfitz.co.uk/2008/12/10/more-on-aspnets-broken-error-handling/</link>
		<comments>http://www.nickfitz.co.uk/2008/12/10/more-on-aspnets-broken-error-handling/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 18:09:59 +0000</pubDate>
		<dc:creator>nickfitz</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Common sense]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://www.nickfitz.co.uk/2008/12/10/more-on-aspnets-broken-error-handling/</guid>
		<description><![CDATA[More on ASP.NET's peculiar approach to HTTP errors.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve looked a bit more into <a href="http://www.nickfitz.co.uk/2008/12/07/why-cant-microsoft-just-use-http-like-everybody-else/">the way ASP.NET handles HTTP errors</a>, and frankly it now seems not just irritating, but downright bizarre.<br />
<span id="more-33"></span><br />
By the way, although the original post was about a <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5">5xx series server error</a>, this also applies to <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4">4xx series client errors</a>. We&#8217;ll take the familiar <code>404 Not Found</code> as an example case.</p>
<p>Here are the main parts (with some headers and the body omitted) of the response to a broken request for <a href="http://blogs.msdn.com/oldnewthing/default.aspx">Raymond Chen&#8217;s blog</a> &#8211; I deliberately misspelled &#8220;default&#8221; as &#8220;defult&#8221; to trigger a 404:</p>
<p>
<pre><code>
HTTP/1.1 <strong>302 Found</strong>
Date: Wed, 10 Dec 2008 17:46:51 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
CommunityServer: 2.1.61025.2
<strong>Location: /error-notfound.aspx?aspxerrorpath=/oldnewthing/defult.aspx</strong>
Content-Type: text/html; charset=utf-8
Content-Length: 176
</code></pre>
</p>
<p>So, a request for something that is not found returns <code>302 Found</code>. Nice.</p>
<p>What happens when the browser follows the redirection to <code>/error-notfound.aspx?aspxerrorpath=/oldnewthing/defult.aspx</code>? This happens:</p>
<p>
<pre><code>
HTTP/1.1 <strong>404 Not Found</strong>
Date: Wed, 10 Dec 2008 17:46:52 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
CommunityServer: 2.1.61025.2
Content-Type: text/html; charset=utf-8
Content-Length: 11769
</code></pre>
</p>
<p>So, just to get this straight: when something is not found, ASP.NET returns a <code>302 Found</code> response redirecting the client elsewhere. Then, when the redirect is followed, it returns a <code>404 Not Found</code> response, despite the fact that this page clearly <em>has</em> been found, and it was the page that redirected us here that was <em>not</em> found.</p>
<p>Weird. Just plain weird.</p>
<p>Update: an online acquaintance (I don&#8217;t have a URL for him) has pointed me to a page on <cite><abbr title="Microsoft Developer Network">MSDN</abbr></cite> where <a href="http://msdn.microsoft.com/en-us/library/aa479319.aspx">the rationale for this behaviour</a> is presented:</p>
<blockquote cite="http://msdn.microsoft.com/en-us/library/aa479319.aspx"><p>
Redirect creates a new Context, Transfer does not. Redirect requires a round-trip to the browser, Transfer does not. As a result of this round-trip, Redirect rewrites the URL to reflect the location of the error page, Transfer does not.</p>
<p>
If this seems to be an argument in favor of Transfer, it isn&#8217;t. The rationale of the ASP.NET development team is that Redirect <em>accurately displays the URL of the custom error page</em>&#8230;
</p>
</blockquote>
<p>However, at no point is it explained <em>why</em> displaying such an implementation detail to clients is preferable. Given that the article starts with the words:</p>
<blockquote cite="http://msdn.microsoft.com/en-us/library/aa479319.aspx"><p>The quality of a site should be measured not only by how well it works, but by how gracefully it fails.</p>
</blockquote>
<p>it seems strange that it then recommends a technique which causes sites to fail in a singularly graceless manner.</p>
<p>My suggestion would be to modify your ASP.NET application configurations so that the <code>customError</code> capability uses the <code>Transfer</code> technique instead of <code>Redirect</code>. If that </p>
<blockquote><p>&#8230;breaks a tenet of the design philosophy of ASP.NET&#8230;</p>
</blockquote>
<p> then so be it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nickfitz.co.uk/2008/12/10/more-on-aspnets-broken-error-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Can&#8217;t Microsoft Just Use HTTP Like Everybody Else?</title>
		<link>http://www.nickfitz.co.uk/2008/12/07/why-cant-microsoft-just-use-http-like-everybody-else/</link>
		<comments>http://www.nickfitz.co.uk/2008/12/07/why-cant-microsoft-just-use-http-like-everybody-else/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 05:57:39 +0000</pubDate>
		<dc:creator>nickfitz</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Common sense]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://www.nickfitz.co.uk/2008/12/07/why-cant-microsoft-just-use-http-like-everybody-else/</guid>
		<description><![CDATA[A 5xx server error shouldn't redirect the user to a new location. They should be left where they are, ready to retry when the server has recovered.]]></description>
			<content:encoded><![CDATA[<p>A few moments ago I was following a link from Google to Raymond Chen&#8217;s excellent MSDN blog <a href="http://blogs.msdn.com/oldnewthing/default.aspx">The Old New Thing</a>. As has happened to me before, I ended up getting redirected to an ASP.NET error page at a totally different URL, telling me that the site was &#8220;unable to service my request.&#8221;<br />
<span id="more-32"></span><br />
Now, the inability to serve the requested page is fair enough; Raymond has previously mentioned that the <code>blogs.msdn.com</code> site can be slow or overloaded because it comes under such relentless attack from comment spammers.</p>
<p>But a redirect to the absolute URL of an error page? That&#8217;s just annoying. It means that I can&#8217;t try to reload the page to see if the server has recovered from whatever issues are affecting it &#8211; or, more accurately, I can try to reload, but as I&#8217;m now at the absolute URL of the error page, I just keep reloading that.</p>
<p>Unsurprisingly, the HTTP 1.1 standard has already provided for this kind of situation by means of the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4"><code>503 Service Unavailable</code></a> status code:</p>
<blockquote><p>The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay.</p>
</blockquote>
<p>If the <code>blogs.msdn.com</code> people (who, by the way, Raymond is not responsible for) would use this status code to serve their error page for the post on Raymond&#8217;s blog, I could simply come back after a few minutes and try to reload the page, as my browser would still be at the same location. </p>
<p>It&#8217;s also possible that they <em>do</em> send this status code, but with a <code>Location: </code> header to cause the redirect. (The server seems to be back on its feet again now, so I can&#8217;t inspect the HTTP cycle to check.)</p>
<p>Either way, what they do is wrong and broken. <strong>Don&#8217;t</strong> send people somewhere else to explain a <code>5xx Server Error</code> status; simply serve the explanation directly using the appropriate 5xx status code, leaving your visitors ready to try a reload when the server has recovered. Otherwise, you&#8217;ll serve a lot of <code>200 OK</code> responses from your error page, most of them to people who haven&#8217;t noticed that their location bar now points there as they hit <code>[Control | Command]-R</code> in the hope of seeing what they originally came for.</p>
<p>Note: A more recent post <a href="http://www.nickfitz.co.uk/2008/12/10/more-on-aspnets-broken-error-handling/">examines this aspect of ASP.NET in greater depth</a>, and suggests the use of a configuration option that resolves the problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nickfitz.co.uk/2008/12/07/why-cant-microsoft-just-use-http-like-everybody-else/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE Conditional Comments in XSLT 1.0</title>
		<link>http://www.nickfitz.co.uk/2005/10/27/ie-conditional-comments-in-xslt-10/</link>
		<comments>http://www.nickfitz.co.uk/2005/10/27/ie-conditional-comments-in-xslt-10/#comments</comments>
		<pubDate>Thu, 27 Oct 2005 18:47:04 +0000</pubDate>
		<dc:creator>nickfitz</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[XSLT 1.0]]></category>

		<guid isPermaLink="false">http://www.nickfitz.co.uk/?p=7</guid>
		<description><![CDATA[Think you can't use Internet Explorer for Windows' conditional comments in XSLT 1.0? Think again...]]></description>
			<content:encoded><![CDATA[<p>Zen gardener Dave Shea&#8217;s post <a href="http://www.mezzoblue.com/archives/2005/10/13/bye_bye_tan_/">Bye Bye Tan Hack</a> attracted a number of comments from people claiming that <a href="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/ccomment_ovw.asp">Internet Explorer&#8217;s conditional comments</a> (CCs) were ungeneratable if you are using XSLT to produce your pages. &#8220;Strange,&#8221; I thought, &#8220;I&#8217;ve done that before.&#8221;<br />
<span id="more-7"></span><br />
I&#8217;ve been working with XSLT for several years, and the project I&#8217;m currently working on uses it intensively; getting CCs working was simmering somewhere down my todo list. (I couldn&#8217;t recycle any previous efforts for boring, legal IP reasons.) So I set to work, and am happy to present an XSLT template which will build your conditional comments for you. I&#8217;ve tested it with Xalan 2.2, Saxon 6.5.3, MSXML 3 and MSXML 4 (those being the only XSLT processors I had to hand), and it worked perfectly with all of them.</p>
<p>In addition, I&#8217;ve created a <a href="/xslt/cc/ConditionalCommentDemo.xml">demonstration</a> for Firefox, Internet Explorer and Safari (2.0.1 on Tiger, anyway). This XML file uses an XSL stylesheet which generates a conditional comment. Using Firefox&#8217;s DOM Inspector you can see that the comment is created correctly. Using Internet Explorer, a stylesheet is linked which modifies the appearance of the page&#8217;s heading. This demonstrates that the technique I&#8217;m describing can be used client-side as well as in server-side transformations.</p>
<p>First, the template:</p>
<pre><code>
&lt;xsl:template name="conditionalComment">
    &lt;xsl:param name="qualifier" select="'IE'"/>
    &lt;xsl:param name="contentRTF" select="''" />
    &lt;xsl:comment>[if &lt;xsl:value-of select="$qualifier"/>]&lt;![CDATA[>]]&gt;
        &lt;xsl:copy-of select="$contentRTF" />
        &lt;![CDATA[&lt;![endif]]]&gt;&lt;/xsl:comment>
&lt;/xsl:template>
</code></pre>
<p>Easy, yes? Well, maybe not; let&#8217;s look at it one step at a time.</p>
<p>The template takes two parameters:</p>
<dl>
<dt><code>qualifier</code></dt>
<dd>The qualifier for the &#8220;if&#8221; clause of the comment. Defaults to &#8220;IE&#8221;, which targets any version of Internet Explorer that recognises conditional comments.</dd>
<dt><code>contentRTF</code></dt>
<dd>The body of the comment: the stuff that IE gets to see (depending on the qualifier). This is passed as a result tree fragment; if you&#8217;re not sure what that means, you may want to go and read the <a href="http://www.w3.org/TR/xslt#section-Result-Tree-Fragments">relevant section of the XSLT spec</a>. Defaults to an empty string.</dd>
</dl>
<p>We can invoke the template using the following code:</p>
<pre><code>
&lt;xsl:call-template name="conditionalComment">
    &lt;xsl:with-param name="qualifier" select="'lte IE 6'"/>
    &lt;xsl:with-param name="contentRTF">
        &amp;lt;link rel="stylesheet" type="text/css" href="ie-win-fixup.css" /&amp;gt;
    &lt;/xsl:with-param>
&lt;/xsl:call-template>
</code></pre>
<p>That will give us a conditional comment targeting Internet Explorer versions 6 and below (&#8220;lte IE 6&#8243;). NOTE: I haven&#8217;t messed up my character entities there; the HTML we want to output really is expressed as you see above in the XSLT code.</p>
<p>So how does it work?</p>
<p>The comment is generated using the <xsl :comment> element. Note that we want to keep tight control of our whitespace here, making the rest of the template pretty unreadable. Split into its component parts, we have:</p>
<dl>
<dt><code>&lt;xsl:comment></code></dt>
<dd>Starts outputting our comment to the result tree. Output so far: <code>&lt;!--</code></dd>
<dt><code>[if &lt;xsl:value-of select="$qualifier"/>]</code></dt>
<dd>Starts adding on the bits needed to make IE parse this as a conditional comment, using the value of the qualifier parameter. In the example case, our output is now up to <code>&lt;!--[if lte IE 6]</code></dd>
<dt><code>&lt;![CDATA[>]]&gt;</code></dt>
<dd>This CDATA section is treated as raw characters to copy to the result tree by the XSLT processor. So our output becomes:<br />
<code>&lt;!--[if lte IE 6]></code> which is the start of our conditional comment.</dd>
<dt><code>&lt;xsl:copy-of select="$contentRTF"/></code></dt>
<dd>This just copies the contents of our result tree fragment to the result tree. Our output is now:</p>
<pre><code>
&lt;!--[if lte IE 6]>
&lt;link rel="stylesheet" type="text/css" xhref="ie-win-fixup.css" mce_href="ie-win-fixup.css" />
</code></pre>
<p>Notice that the character entity references we passed in in contentRTF (<code>&amp;lt;</code> and <code>&amp;gt;</code>) have now been turned into the actual characters we wanted, through the magic of result tree fragments. (In fact, this technique can be abused to allow invalid XML output from an XSLT processor, which is why it isn&#8217;t likely to survive into XSLT 2.0.)</dd>
<dt><code>&lt;![CDATA[>![endif]]]&gt;</xsl:comment></code></dt>
<dd>Our final line uses another CDATA section to provide the markup IE needs to recognise the end of the comment, and then the <code></xsl:comment></code> closes our comment. Note again that there is no whitespace between the CDATA section and the closing-comment element: this is where IE&#8217;s CC parser might trip up, so we make do with a little unreadability for the sake of getting the result we want which, in all its refulgent splendour, now looks like:</p>
<pre><code>
&lt;!--[if lte IE 6]>
&lt;link rel="stylesheet" type="text/css" href="ie-win-fixup.css" />
&lt;![endif]-->
</code></pre>
</dd>
</dl>
<p>So there you have it: an XSLT template for creating Internet Explorer conditional comments. Hopefully re-targeting your CSS hacks in readiness for the new age just got a little easier.</p>
<p class="update">
This post is now <a href="http://webhostinggeeks.com/science/comments-xslt-rm">available in a Romanian translation</a> (by <a href="http://webhostinggeeks.com/">Web Geek Science</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nickfitz.co.uk/2005/10/27/ie-conditional-comments-in-xslt-10/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Obscure Internet Explorer Bugs: #1 of&#8230; who knows?</title>
		<link>http://www.nickfitz.co.uk/2005/05/17/obscure-internet-explorer-bugs-1-of-who-knows/</link>
		<comments>http://www.nickfitz.co.uk/2005/05/17/obscure-internet-explorer-bugs-1-of-who-knows/#comments</comments>
		<pubDate>Tue, 17 May 2005 19:51:22 +0000</pubDate>
		<dc:creator>nickfitz</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://www.nickfitz.co.uk/?p=2</guid>
		<description><![CDATA[<p>
A very peculiar bug in Internet Explorer: ever seen a tagName begin with a <code>/</code> before?
</p>]]></description>
			<content:encoded><![CDATA[<p>The Web Standards Group presented <a href="http://webstandardsgroup.org/features/tommy-olsson.cfm">ten questions</a> to <a href="http://autisticcuckoo.net/">Tommy Olsson</a>, one of which addresses the thorny issue of the <code>abbr</code> and <code>acronym</code> elements in HTML.<br />
<span id="more-2"></span><br />
Tommy&#8217;s discussion of this was informative, and I was particularly entertained by his assertion that</p>
<blockquote><p>Netscape invented ABBR, while Microsoft invented ACRONYM, and both types meant the same thing. Then the W3C incorporated both in HTML 3, but with subtly different semantics. Microsoft&#8217;s meaning of ACRONYM was replaced by something different, which made the people at Microsoft so furious that to this day they still don&#8217;t support the ABBR element type!</p></blockquote>
<p>as I came across a manifestation of this (possibly imaginary) dislike for the <code>abbr</code> element in Internet Explorer quite recently.</p>
<p>Consider the following markup fragment:</p>
<p><code></p>
<p>An example of an abbreviation might be <abbr title="Limited Liability Company">Ltd.</abbr>, used in the UK to denote a private company with limited liability.</p>
<p></code></p>
<p>One would expect a browser which supports <a href="http://www.w3.org/TR/html401/">HTML 4</a> (which IE is claimed to have done since <a href="http://msdn.microsoft.com/workshop/essentials/versions/xplatform.asp">version 4</a>) to produce a DOM structure as follows:</p>
<ul>
<li>Element: <strong>p</strong>
<ul>
<li>Text: <em>An example of an abbreviation might be </em></li>
<li>Element: <strong>abbr</strong>
<ul>
<li>Text: <em>Ltd.</em></li>
</ul>
</li>
<li>Text: <em>, used in the UK to denote a private company with limited liability.</em></li>
</ul>
</li>
</ul>
<p>Whereas IE actually produces the following:</p>
<ul>
<li>Element: <strong>p</strong>
<ul>
<li>Text: <em>An example of an abbreviation might be </em></li>
<li>Element: <strong>abbr</strong></li>
<li>Text: <em>Ltd.</em></li>
<li>Element: <strong style="color: red">/abbr</strong></li>
<li>Text: <em>, used in the UK to denote a private company with limited liability.</em></li>
</ul>
</li>
</ul>
<p>Yes, that&#8217;s correct: the initial <code>abbr</code> is parsed into an element, the text within remains as a <code>childNode</code> of the paragraph, and an element with the name <code>/abbr</code> is created.</p>
<p>If you try to use the <code>createElement</code> method of the <code>document</code> to create such an element, you naturally get an exception. But internally, IE manages to create an element whose name begins with a slash.</p>
<p>I don&#8217;t have a PC at home, so I can&#8217;t check right now whether or not spurious markup like <code><goat>Hello</goat></code> produces the same result, but I&#8217;ll check at work tomorrow and report back.</p>
<p><em>Long-delayed update</em>: The <goat> example above does indeed produce the same results.</goat></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nickfitz.co.uk/2005/05/17/obscure-internet-explorer-bugs-1-of-who-knows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

