I got assigned a rather annoying bug today whereby when a user using Firefox 7 went to a page that streamed a file for download, Firefox immediately stopped processing the page and returned the following error

Corrupted Content Error

A little bit of GoogleFu brought me to Firefox Bug #681140 - Corrupted Content error due to multiple Content-Disposition header field instances, new in Firefox 7.

There are a couple of reasons why this error will get thrown but the bottom line is Firefox thinks this is a form of response-smuggling and blocks it, in fact it doesn’t just block it, it denies any knowledge of anything to do with it, I could not for the life of me get Firefox to give me the response headers no matter what extension I used. In the end fiddler revealed the issue

content-disposition: attachment
Content-Disposition: attachment; filename="results.xls"

Fairly simple issue here, there are two Content-Disposition headers being sent to the browser and Firefox 7 throws it’s toys out of the pram if there is more than one.

Now, the cause.

I loaded up the controller that was generating these downloads and right enough, I found

Response.AddHeader("content-disposition", "attachment");
return File(content, format, filename);

I think you can see where I am going here. MVC is pretty good at removing a lot of the boiler plate we normally have to write and this is one of those cases. When you use the Controller.File method a number of headers are automatically set for you on the Response stream, if you provide a file name then one of those headers is Content-Disposition.

Ta-da, the source of the duplication.

So, when using FileResult in MVC, be very careful which additional headers you send out, check them in something like fiddler and don’t just assume that browsers in the future will accept malformed or duplicate headers.

Posted in MVC.

jquery-vsdoc
Update: John Resig has uploaded the official vsdoc file for jQuery 1.3.1, the workaround posted below is obsolete. You can find the updated file

 at http://docs.jquery.com/Downloading_jQuery.

After the release of jQuery 1.3 earlier this month, those of you who have made use of the extended Visual Studio 2008 support for jQuery will no doubt have discovered the new version is not compatable with the 1.2.6 vsdoc.js file.

James Hart, has come to our rescue with the creation of a 1.3 compatible vsdoc.js file however it should be noted the structure for this file is different from the structure Microsoft used in the 1.2.6 file. As such there may be compatibility issues such as problems when working with extensions, just something to keep in mind.

There has not been any comment from Microsoft on an updated vsdoc file with 1.3 support.

3 Posts in 24 hours, am I feeling OK?jquery

The next major version of the popular javascript framework jQuery (1.3) is almost finished with just the last few bugs to be tracked down. John Resig, lead developer and creator of jQuery published the beta of jQuery 1.3 back in the middle of December and yesterday announced on his twitter feed that 1.3 RC1 was out although this was quickly followed with a mention that RC2 would be required due to last minute bugs. The expected release date of 1.3 is the 14th of January as indicated on the beta announcement blog post.

A summary of what’s new in 1.3:

  • Selector Engine – The selector code has undergone a complete rewrite – it’s likely that some edge cases still exist here.
  • DOM Manipulation (append/prepend/before/after) – This code has also undergone a large rewrite along with some of the logic for executing inline script elements.
  • .offset() – Another method that has been completely rewritten.
  • Event Namespaces – The logic for handling namespaced events has been completely rewritten.
  • Event Triggering – When triggering an event the event now bubbles up the DOM – this is likely to cause some problems.

I have yet to have a play with the new version and indeed probably wont get the chance until it hits release but it is reassuring to see performance enhancements being implemented in this release as well as removing all browser sniffing code. I will add a little bit to my jQuery talk about the latest version.

Given how fast popularity for the jQuery JavaScript Framework has grown I figured collating a number of resources together would be a good idea. Feel free to post comments with more to add to the list. More to come soon.

The basics

UI

Plugins

Development

Well, although it is half way though January, Happy New Year. I have not been posting as much as I would like but that should get turned around soon.

Today saw my first game of Warhammer 40k in 2009 and it very painfully showed me that some of the changes in 5th edition have made Tyranids even harder to play (automatically passing morale checks in a lost combat now kills hormaganuts very effectively, more so than 4th edition), still was a good game and I have some new tricks up my sleeve for next time. For the record: I hate Tau!

Geekery out of the way, time for some more, er, geekery. I will be giving two talks on jQuery in the coming months which may be of interest to those either in the Tayside area of Scotland or those willing to travel to Edinburgh. These will be my first public talks outside of university and I am excited to see how they turn out since interest thus far has been quite good.

Abstractjquery

A new client-side framework has been taking the internet by storm, many have already been mesmerised by the power of such a small javascript library. And “what is the name of this fantastic framework?” I hear you ask, “jQuery” is my reply.

jQuery is a robust javascript framework with a very small footprint (15kb minified and GZipped) which makes the complicated aspects of javascript very simple. From traversing the Document Object Model to complex AJAX functionality, jQuery can do it all.

In this session I will introduce you to the basics of jQuery, showing you, through code, how to select and manipulate elements on the page, attach functions to events, implement ajax and more! This is the perfect opportunity to learn about jQuery and how it can make the life of web developer so much easier, allowing you to focus more on building your application!

Both talks are the same, An Introduction To jQuery, however there are two different venues and dates.

As with other Scottish Developers events, both sessions are completely free and all are encouraged to come along. If interested, it you be greatly appreciated if you could register for the events using the links above to give us an idea of number.