From: Mark Rendle on
Hi

We've got an ASP.NET application which writes file output directly to the
Response stream. It uses the content-disposition attachment header to force
the browser to display a "Save/Open" dialog for known mime-types. When
running in IIS5 on Windows 2000 Pro or Windows XP Professional (i.e. our
development PCs) and using IE6 this works fine. When deployed to a Windows
2003 server running IIS6, and accessing the page using IE6, it all goes
wrong. Instead of the specified filename, the name of the aspx page is
given, along with all the usual warnings about script etc. (Accessing the
page with Mozilla Firefox works fine.)

I created a test application which reproduces this behaviour, and noticed
something even stranger: when I open a new browser window and enter the URL,
I get the bug behaviour. If I click cancel, and then press enter to load the
page again, it works fine.

I've accessed the page using WFetch from the IIS6 RK, with the results as
follows:

---------------------------------------------------------------------------------------
started....
WWWConnect::Connect("dexter","80")\nIP = "10.0.3.125:80"\nsource port:
3207\r\n
REQUEST: **************\nGET /DownloadTest/default.aspx HTTP/1.1\r\n
Host: dexter\r\n
Accept: */*\r\n
\r\n
RESPONSE: **************\nHTTP/1.1 200 OK\r\n
Date: Fri, 16 Sep 2005 12:13:49 GMT\r\n
Server: Microsoft-IIS/6.0\r\n
MicrosoftOfficeWebServer: 5.0_Pub\r\n
X-Powered-By: ASP.NET\r\n
X-AspNet-Version: 1.1.4322\r\n
Content-Disposition: attachment; filename="mydata.csv"\r\n
Transfer-Encoding: chunked\r\n
Set-Cookie: ASP.NET_SessionId=lbd5gsuycuaql3551uv5k234; path=/\r\n
Cache-Control: private\r\n
Content-Type: text/csv; charset=utf-8\r\n
\r\n
"Name"\r\n
"Alice"\r\n
"Bob"\r\n
finished.
---------------------------------------------------------------------------------------

Is there a patch or workaround for this? It's going to cause a major problem
with our go-live if we can't get this working on this near-universal
combination of IIS6 and IE6.

Cheers
Mark


From: Chris Crowe [MVP] on
I tested this on Windows XP SP2 (IIS 5.1) and Windows 2003 Server SP1 (IIS
6) with IE 6.0.2900.2180.xpsp_sp2_gdr.050301-1519 using the following code
and it works fine for me.

private void Page_Load(object sender, System.EventArgs e)
{
string data="chris,crowe,10/june/2004";
byte[] DataBytes = Encoding.UTF8.GetBytes(data);
Response.ContentType = "text/csv; charset=utf-8";
Response.OutputStream.Write(DataBytes, 0, DataBytes.Length);
Response.AddHeader("Content-Disposition", "inline;filename=temp.csv");
}

Note: Difference in mine is "inline" instead of "attachment"

When I used attachment my download manager tried to take over to download
the file, when inline was used it did not get in the way.

--
Cheers

Chris

Chris Crowe [IIS MVP]
http://blog.crowe.co.nz


"Mark Rendle" <markdotrendleatcomputersoftwaredotcom> wrote in message
news:uy6rAqruFHA.3588(a)tk2msftngp13.phx.gbl...
> Hi
>
> We've got an ASP.NET application which writes file output directly to the
> Response stream. It uses the content-disposition attachment header to
> force the browser to display a "Save/Open" dialog for known mime-types.
> When running in IIS5 on Windows 2000 Pro or Windows XP Professional (i.e.
> our development PCs) and using IE6 this works fine. When deployed to a
> Windows 2003 server running IIS6, and accessing the page using IE6, it all
> goes wrong. Instead of the specified filename, the name of the aspx page
> is given, along with all the usual warnings about script etc. (Accessing
> the page with Mozilla Firefox works fine.)
>
> I created a test application which reproduces this behaviour, and noticed
> something even stranger: when I open a new browser window and enter the
> URL, I get the bug behaviour. If I click cancel, and then press enter to
> load the page again, it works fine.
>
> I've accessed the page using WFetch from the IIS6 RK, with the results as
> follows:
>
> ---------------------------------------------------------------------------------------
> started....
> WWWConnect::Connect("dexter","80")\nIP = "10.0.3.125:80"\nsource port:
> 3207\r\n
> REQUEST: **************\nGET /DownloadTest/default.aspx HTTP/1.1\r\n
> Host: dexter\r\n
> Accept: */*\r\n
> \r\n
> RESPONSE: **************\nHTTP/1.1 200 OK\r\n
> Date: Fri, 16 Sep 2005 12:13:49 GMT\r\n
> Server: Microsoft-IIS/6.0\r\n
> MicrosoftOfficeWebServer: 5.0_Pub\r\n
> X-Powered-By: ASP.NET\r\n
> X-AspNet-Version: 1.1.4322\r\n
> Content-Disposition: attachment; filename="mydata.csv"\r\n
> Transfer-Encoding: chunked\r\n
> Set-Cookie: ASP.NET_SessionId=lbd5gsuycuaql3551uv5k234; path=/\r\n
> Cache-Control: private\r\n
> Content-Type: text/csv; charset=utf-8\r\n
> \r\n
> "Name"\r\n
> "Alice"\r\n
> "Bob"\r\n
> finished.
> ---------------------------------------------------------------------------------------
>
> Is there a patch or workaround for this? It's going to cause a major
> problem with our go-live if we can't get this working on this
> near-universal combination of IIS6 and IE6.
>
> Cheers
> Mark
>