468,290 Members | 2,107 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,290 developers. It's quick & easy.

trouble with HttpHandler in firefox 2

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

Jul 11 '07 #1
5 2703

hawkeye parker wrote:
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?

Jul 11 '07 #2
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
Jul 11 '07 #3
"hawkeye parker" <ha*****@gmail.comwrote in message
news:11**********************@o11g2000prd.googlegr oups.com...
>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
"Content-Disposition: attachment;filename=""Small.doc"";"
Those quotes don't belong there...
--
John Saunders [MVP]

Jul 12 '07 #4

hawkeye parker wrote:
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
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

Jul 12 '07 #5
On Jul 12, 12:10 am, marss <marss...@gmail.comwrote:
hawkeye parker wrote:
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

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.

Jul 24 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jed | last post: by
4 posts views Thread by Jeremy Lew | last post: by
9 posts views Thread by Jared Tullis | last post: by
reply views Thread by Mike Lowery | last post: by
3 posts views Thread by Tomasz J | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.