trouble with HttpHandler in firefox 2

Discussion in 'ASP .Net' started by hawkeye parker, Jul 11, 2007.

  1. 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
    hawkeye parker, Jul 11, 2007
    #1
    1. Advertising

  2. hawkeye parker

    marss Guest

    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?
    marss, Jul 11, 2007
    #2
    1. Advertising

  3. > 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
    hawkeye parker, Jul 11, 2007
    #3
  4. "hawkeye parker" <> wrote in message
    news:...
    >> 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]
    John Saunders [MVP], Jul 11, 2007
    #4
  5. hawkeye parker

    marss Guest

    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
    marss, Jul 12, 2007
    #5
  6. On Jul 12, 12:10 am, marss <> wrote:
    > 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.
    hawkeye parker, Jul 24, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hypo
    Replies:
    6
    Views:
    406
  2. V Arzola
    Replies:
    0
    Views:
    519
    V Arzola
    Mar 21, 2006
  3. Rabel
    Replies:
    2
    Views:
    420
    Rabel
    Dec 19, 2006
  4. =?Utf-8?B?Sm9obiBCYWlsZXk=?=

    Trouble getting page to work in FireFox

    =?Utf-8?B?Sm9obiBCYWlsZXk=?=, Mar 24, 2007, in forum: ASP .Net
    Replies:
    9
    Views:
    387
    Damien
    Mar 29, 2007
  5. V Arzola

    Trouble rendering form panels in firefox and netscape

    V Arzola, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    105
    V Arzola
    Mar 21, 2006
Loading...

Share This Page