Welcome to CrankyGoblin.Com Sign in | Join | Help

Public Class GeoffAppleby

Inherits Microsoft.VisualBasic.MVP : Implements IBrainFart
My First SP2 Issue

Yep, I found my first 'bug' associated with XPSP2. But it wasn't a bug, just an interesting behaviour.

At my work we develop a web based reporting application. One of the features is to export the currently viewed report as a csv file. I needed to test an export, so I viewed a report and told it to export...and was promptly faced with a Javascript error.

I had a look at the Javascript, and there was nothing really wrong with it - but I do know that the request back to the web server for the export report is done in a hidden IFrame. 'Uh oh', thinks me, 'There's higher security applied to IFrames now. Bugger'.

I spent a couple of hours scouring SP2 documentation for a change in IE that might be effecting this, also scouring the advanced options and security settings, trying to figure it out. I won't bore you with the specifics, but I found the problem and fixed it right up in our source ASP files (yeah, classic ASP, not .net...*sigh* Worse still, they're in JScript). It was a bug in the code, which of course was not written by me, but a developer who's now left the company. Grrrr.

So, the results of my investigation is this: When you want to return a document stream as a download from your ASP code, you set the 'Content-Disposition' header on the reponse object, specifying the filename of the attachment.

Here's the before code:

Response.Expires = -1;
Response.ContentType = "text/csv";
Response.AddHeader("Content-Disposition", "filename=Report" + iReportID + ".csv;");

And here's the after code:

Response.Expires = -1;
Response.ContentType = "text/csv";
Response.AddHeader("Content-Disposition", "attachment; filename=Report" + iReportID + ".csv;");

See the difference? That one word: attachment. Yes, it's actually always supposed to have been there. It seems prior to XPSP2, IE was basically seeing the headers and saying 'well, you know, i can see what you meant, so close enough'.

And now it's being strict about it. I think this is a good thing, but man I was tearing my hair out for a while there! So if you ever click a link and expect a 'open or save' popup and you run SP2, try checking to see if the guy that used to work here now works for you *grin*.

Listening to: demons - fat boy slim feat. macy gray - (6:54)
Posted: Thursday, August 19, 2004 1:51 PM by Geoff Appleby

Comments

webmaster said:

Thanks Geoff, helped me a lot.


# August 23, 2004 5:33 PM

Joseph said:

Hi,
Tat was really wonderful help. I had changed the content type to "application/x-excel" and then add the word attachment; but ur code seems to be more wonderful.
# August 27, 2004 9:38 PM

duke said:

I can't get the .csv extension type added on the save as type. It loads it with a document extension.
# October 28, 2004 1:09 AM

Mike said:

I have an application that also downloads reports using content-disposition of attachment. Here is the rub. My application is started from a portal via a window.open(). Now when someone downloads a report, my app browser window closes! I can't find a workaround for this. Anyone run across this?
# November 11, 2004 5:38 AM

me said:

hey yeah mike i have the same problem with a popup that was desinged around a javascript:void(location.href="URL");

Window pops up for a split second and then goes right back down. it also makes a ding like IE has blocked a popup. Needless to say the popup blocker is OFF. I have also tried to lower all security settings to their lowerst levels to no effect.

My guess is some kind of hidden popup blocker that doesnt let you run javascript from outside of the browser. THis kind of sucks balls as i cannot write javascript so i cant even put together a work around. I have found this post while searching on google. Pre SP2 Machines are not affected.

There must be a registry setting to disable this "functionality".
# February 11, 2005 6:29 AM

me again said:

OK
so i found a fix because i was talking to some programmers about it. Then i thought, hey i bet IE will take a url if i just pass it after the executable name.

iexplore http://foobar.com

works great for my purposes and loads up correctly.
# February 11, 2005 6:48 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

To submit your comment, click on these pictures:
  • Geoff's mother on a booger hunt
  • Searching Geoff
  • Geoff's little sister's pussy
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Can't recognise the people in these pictures? Look here for a quick introduction.
There's a time limit for you to get your comment submitted before this set of pictures expires. If you think it's been longer than 10 minutes, get some new pictures first (you won't lose what you've typed so far).
Get some new pictures 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS