trouble with HttpHandler in firefox 2

H

hawkeye parker

Hello,

IIS 6.0 server, .Net 2.0. I have a file download architecture which
redirects
file download requests to a custom server-side HttpHandler. The
handler gets a stream over the file and "returns" the file via
HttpContext.Response.OutputStream.Write.

This works fine in IE, but with Firefox, I get different behavior: I
see no "save as" dialog for the file download ("Always ask me where
to
save files" is enabled), and from the user perspective, it seems as
though nothing happens.

The redirect seems to be successful: I can debug into the handler
just fine. While stepping through the handler, everything appears to
be "working" just fine, but there are a few strange things that
happen:

1) HttpContext.Response.IsClientConnected returns false (with IE
this
returns true).
2) Even though I'm still writing the file stream to
HttpContext.Response.OutputStream.Write, the client (Firefox) doesn't
respond to this.

I've tried using a Content-Dispostion header, with no luck.

Do these symptoms suggest anything to anyone?

Thanks in advance,

Hawkeye Parker
 
M

marss

hawkeye said:
Hello,

IIS 6.0 server, .Net 2.0. I have a file download architecture which
redirects
file download requests to a custom server-side HttpHandler. The
handler gets a stream over the file and "returns" the file via
HttpContext.Response.OutputStream.Write.

This works fine in IE, but with Firefox, I get different behavior: I
see no "save as" dialog for the file download ("Always ask me where
to
save files" is enabled), and from the user perspective, it seems as
though nothing happens.

The redirect seems to be successful: I can debug into the handler
just fine. While stepping through the handler, everything appears to
be "working" just fine, but there are a few strange things that
happen:

1) HttpContext.Response.IsClientConnected returns false (with IE
this
returns true).
2) Even though I'm still writing the file stream to
HttpContext.Response.OutputStream.Write, the client (Firefox) doesn't
respond to this.

I've tried using a Content-Dispostion header, with no luck.

Do these symptoms suggest anything to anyone?

Thanks in advance,

Hawkeye Parker

Are you assign Response.ContentType property according to your file?
 
H

hawkeye parker

Are you assign Response.ContentType property according to your file?- Hide quoted text -
Yes. Yere's a sample header:

4 2 HTTP/1.1 200 OK IEXPLORE (2760) 0x12C8
Date: Mon, 09 Jul 2007 21:22:24 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Content-Length: 19968
"Content-Disposition:
attachment;filename=""Small.doc"";"
Cache-Control: private
Content-Type: application/msword
 
M

marss

hawkeye said:
Yes. Yere's a sample header:

4 2 HTTP/1.1 200 OK IEXPLORE (2760) 0x12C8
Date: Mon, 09 Jul 2007 21:22:24 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Content-Length: 19968
"Content-Disposition:
attachment;filename=""Small.doc"";"
Cache-Control: private
Content-Type: application/msword

I made some test example.
I added Handler1.ashx in project. Code:
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/msword";
byte[] cont =
System.IO.File.ReadAllBytes(context.Server.MapPath("~/MSF.doc"));
System.IO.MemoryStream ms = new System.IO.MemoryStream(cont);
ms.WriteTo(context.Response.OutputStream);
}
public bool IsReusable
{
get
{
return false;
}
}
}

In .aspx file:
<a href="Handler1.ashx">MSF.doc</a>

No more actions. Everything works in IE and Firefox.

Regards,
Mykola
http://marss.co.ua
 
H

hawkeye parker

Yes. Yere's a sample header:
4 2 HTTP/1.1 200 OK IEXPLORE (2760) 0x12C8
Date: Mon, 09 Jul 2007 21:22:24 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Content-Length: 19968
"Content-Disposition:
attachment;filename=""Small.doc"";"
Cache-Control: private
Content-Type: application/msword

I made some test example.
I added Handler1.ashx in project. Code:
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/msword";
byte[] cont =
System.IO.File.ReadAllBytes(context.Server.MapPath("~/MSF.doc"));
System.IO.MemoryStream ms = new System.IO.MemoryStream(cont);
ms.WriteTo(context.Response.OutputStream);
}
public bool IsReusable
{
get
{
return false;
}
}

}

In .aspx file:
<a href="Handler1.ashx">MSF.doc</a>

No more actions. Everything works in IE and Firefox.

Regards,
Mykolahttp://marss.co.ua- Hide quoted text -

- Show quoted text -

Many thanks Mykola. Yeah, that absolutely works. I'm still having a
problem which I'll address in a separate thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top