473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2806

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hanse Davion | last post by:
Can anyone provide some insight on what this problem could be? I have searched the web, read forums, and all the installation documentation for the dotnetnuke feeware portal from asp.net. I am...
3
by: Jed | last post by:
I have written an HttpHandler which I invoke through an ashx page. The HttpHandler does various things to process the request, then it is supposed to redirect to a confirmation page. Everything...
4
by: Jeremy Lew | last post by:
When my HttpHandler is processing a request when installed on a particular 2003 Server machine, the Context.Session object is null. Any idea why this might be? My handler implements...
3
by: Ralf Müller | last post by:
hi all! in my custom HttpHandler HttpContext.Current.Session is not set - why? greetings, ralf
9
by: Jared Tullis | last post by:
We have an .NET 1.1 application running on 4 2K3 load balanced servers (using WLBS). IIS has the .NET aspnet_isapi.dll mapped as a wildcard application map. The web.config points *.html to a...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
0
by: Mike Lowery | last post by:
I've written an HTTPHandler based on the article at http://msdn2.microsoft.com/en-us/library/ms228090.aspx. It's working, but I have one problem. What I'm trying to do is redirect the browser...
5
by: zlf | last post by:
Hello, I try to use a custom HttpHandler to add something to session, then display the original page. public void ProcessRequest(HttpContext context) { context.Session = "test"; } But, a...
3
by: Tomasz J | last post by:
Hello Developers, I have a following problem: I need to write a HttpHandler rewriting requests like: /Resource.axd?resid=1 to /someimage.gif My HttpHandler is listed in the web.config, its...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.