Downloaded document has disappeared by the time Word has opened

Discussion in 'ASP .Net' started by Rob Nicholson, Aug 31, 2005.

  1. We've implemented functionality to allow a user to download a document (any
    document type) from the IIS server using the following code:

    Response.Clear()
    Response.ContentType = "application/x-msdownload"
    Response.AddHeader("Content-Disposition", "attachment; filename=" &
    System.IO.Path.GetFileName(FilePath))
    Response.AddHeader("Content-Length", File.Length.ToString())
    Response.WriteFile(FilePath)
    Response.End()

    When this response is sent back, IE prompts the user whether they want to
    open, save or cancel the download. It works perfectly if they save the
    document to their local hard drive and then open it. However, if they select
    Open, the file downloads (quickly) but by the time Word opens, the copy in
    temporary internet files has either disappeared or never saved in the first
    place. Word displays an error about "The file could not be found".

    I suspect it's something to do with caching but whilst I can find many posts
    about stopping caching, I can't find any good examples in ASP.NET about
    forcing the Word document to cache.

    Any ideas?

    Thanks, Rob.
    Rob Nicholson, Aug 31, 2005
    #1
    1. Advertising

  2. It seems as if the content-type specifically says it is for downloading. Try
    using "application/doc" for Word files. This will tell the browser to open
    it. The user then can optionally save it locally.

    Or, try setting the "content-expiration" setting for the directory in IIS to
    expire in one minute(versus immediately). Word, PDF, and others have had a
    problem being opened in the browser with expire-immediately.

    "Rob Nicholson" wrote:

    > We've implemented functionality to allow a user to download a document (any
    > document type) from the IIS server using the following code:
    >
    > Response.Clear()
    > Response.ContentType = "application/x-msdownload"
    > Response.AddHeader("Content-Disposition", "attachment; filename=" &
    > System.IO.Path.GetFileName(FilePath))
    > Response.AddHeader("Content-Length", File.Length.ToString())
    > Response.WriteFile(FilePath)
    > Response.End()
    >
    > When this response is sent back, IE prompts the user whether they want to
    > open, save or cancel the download. It works perfectly if they save the
    > document to their local hard drive and then open it. However, if they select
    > Open, the file downloads (quickly) but by the time Word opens, the copy in
    > temporary internet files has either disappeared or never saved in the first
    > place. Word displays an error about "The file could not be found".
    >
    > I suspect it's something to do with caching but whilst I can find many posts
    > about stopping caching, I can't find any good examples in ASP.NET about
    > forcing the Word document to cache.
    >
    > Any ideas?
    >
    > Thanks, Rob.
    >
    >
    >
    >
    >
    =?Utf-8?B?QnJhZCBSb2JlcnRz?=, Aug 31, 2005
    #2
    1. Advertising

  3. Hi Rob,

    I think you can try Brad's suggestion on adjusting the Content Type
    property of your response object. Based on the code you provided, there
    seems no other particular things except the content-type value. Generally,
    we can always use the "application/octet-stream" for all binary data
    streams.
    If there're any other findings, please feel free to post here.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | Thread-Topic: Downloaded document has disappeared by the time Word has
    opened
    | thread-index: AcWuaqCYbyNdCVghSemc2lRBU+nUxA==
    | X-WBNR-Posting-Host: 129.54.8.45
    | From: =?Utf-8?B?QnJhZCBSb2JlcnRz?= <>
    | References: <uDvCh$>
    | Subject: RE: Downloaded document has disappeared by the time Word has
    opened
    | Date: Wed, 31 Aug 2005 13:29:03 -0700
    | Lines: 40
    | Message-ID: <>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="Utf-8"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | Content-Class: urn:content-classes:message
    | Importance: normal
    | Priority: normal
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:121534
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | It seems as if the content-type specifically says it is for downloading.
    Try
    | using "application/doc" for Word files. This will tell the browser to
    open
    | it. The user then can optionally save it locally.
    |
    | Or, try setting the "content-expiration" setting for the directory in IIS
    to
    | expire in one minute(versus immediately). Word, PDF, and others have had
    a
    | problem being opened in the browser with expire-immediately.
    |
    | "Rob Nicholson" wrote:
    |
    | > We've implemented functionality to allow a user to download a document
    (any
    | > document type) from the IIS server using the following code:
    | >
    | > Response.Clear()
    | > Response.ContentType = "application/x-msdownload"
    | > Response.AddHeader("Content-Disposition", "attachment; filename=" &
    | > System.IO.Path.GetFileName(FilePath))
    | > Response.AddHeader("Content-Length", File.Length.ToString())
    | > Response.WriteFile(FilePath)
    | > Response.End()
    | >
    | > When this response is sent back, IE prompts the user whether they want
    to
    | > open, save or cancel the download. It works perfectly if they save the
    | > document to their local hard drive and then open it. However, if they
    select
    | > Open, the file downloads (quickly) but by the time Word opens, the copy
    in
    | > temporary internet files has either disappeared or never saved in the
    first
    | > place. Word displays an error about "The file could not be found".
    | >
    | > I suspect it's something to do with caching but whilst I can find many
    posts
    | > about stopping caching, I can't find any good examples in ASP.NET about
    | > forcing the Word document to cache.
    | >
    | > Any ideas?
    | >
    | > Thanks, Rob.
    | >
    | >
    | >
    | >
    | >
    |
    Steven Cheng[MSFT], Sep 1, 2005
    #3
  4. > using "application/doc" for Word files. This will tell the browser to open

    The problem with this is that don't we then have to code/cater for every
    different content type in the program and generate different content-types?

    > Or, try setting the "content-expiration" setting for the directory in IIS

    to
    > expire in one minute(versus immediately). Word, PDF, and others have had a
    > problem being opened in the browser with expire-immediately.


    Ahh this might be more useful. Which directory do you set the expiry on as
    the source folder varies?

    Thanks, Rob.
    Rob Nicholson, Sep 1, 2005
    #4
  5. > seems no other particular things except the content-type value. Generally,
    > we can always use the "application/octet-stream" for all binary data


    Hi Steven,

    We originally had "application/octet-stream" in there but the problem we
    were having then on the test IIS 5 server was that the prompt to save never
    appeared at all although it worked fine in the development environment.

    Anyone know of a good reference for HTML responses esp. these binary ones?
    The documentation in MSDN is very much at the reference level in describing
    each of the methods/properties of Reponse.Cache, not necessarily what they
    are used for.

    Thanks, Rob
    Rob Nicholson, Sep 1, 2005
    #5
  6. Hi Rob,

    Thanks for your response. I'm really feeling strange that the
    "Application/octet-stream" not work on your product server. The
    "application/octet-stream" just means normal binary stream and is used
    when you didn't sure on the specific content-type or your custom stream.
    This must be a environment specific problem. Also, have you tried testing
    the page from some other client machines to see whether this is a client
    specific problem? For the specification on HTTP request/response message or
    content-type, cache ,setting, you can refer to the HTTP 1.1 rfc , but I
    think the asp.net has completely encapsulated most of them so that we don't
    need to care about the underlying details.

    Thanks,

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    --------------------
    | From: "Rob Nicholson" <>
    | References: <uDvCh$>
    <>
    <>
    | Subject: Re: Downloaded document has disappeared by the time Word has
    opened
    | Date: Thu, 1 Sep 2005 09:23:00 +0100
    | Lines: 17
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.3790.181
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
    | Message-ID: <OW0#>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: host217-45-2-106.in-addr.btopenworld.com 217.45.2.106
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:121650
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | > seems no other particular things except the content-type value.
    Generally,
    | > we can always use the "application/octet-stream" for all binary data
    |
    | Hi Steven,
    |
    | We originally had "application/octet-stream" in there but the problem we
    | were having then on the test IIS 5 server was that the prompt to save
    never
    | appeared at all although it worked fine in the development environment.
    |
    | Anyone know of a good reference for HTML responses esp. these binary ones?
    | The documentation in MSDN is very much at the reference level in
    describing
    | each of the methods/properties of Reponse.Cache, not necessarily what they
    | are used for.
    |
    | Thanks, Rob
    |
    |
    |
    Steven Cheng[MSFT], Sep 2, 2005
    #6
  7. Hi Rob,

    Have you got any further progress on this issue? If there're any further
    things we can help, please feel free to post here. Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | X-Tomcat-ID: 206198363
    | References: <uDvCh$>
    <>
    <>
    <OW0#>
    | MIME-Version: 1.0
    | Content-Type: text/plain
    | Content-Transfer-Encoding: 7bit
    | From: (Steven Cheng[MSFT])
    | Organization: Microsoft
    | Date: Fri, 02 Sep 2005 11:50:18 GMT
    | Subject: Re: Downloaded document has disappeared by the time Word has
    opened
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | Lines: 64
    | Path: TK2MSFTNGXA01.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:121977
    | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
    |
    | Hi Rob,
    |
    | Thanks for your response. I'm really feeling strange that the
    | "Application/octet-stream" not work on your product server. The
    | "application/octet-stream" just means normal binary stream and is used
    | when you didn't sure on the specific content-type or your custom stream.
    | This must be a environment specific problem. Also, have you tried testing
    | the page from some other client machines to see whether this is a client
    | specific problem? For the specification on HTTP request/response message
    or
    | content-type, cache ,setting, you can refer to the HTTP 1.1 rfc , but I
    | think the asp.net has completely encapsulated most of them so that we
    don't
    | need to care about the underlying details.
    |
    | Thanks,
    |
    | Regards,
    |
    | Steven Cheng
    | Microsoft Online Support
    |
    | Get Secure! www.microsoft.com/security
    | (This posting is provided "AS IS", with no warranties, and confers no
    | rights.)
    |
    | --------------------
    | | From: "Rob Nicholson" <>
    | | References: <uDvCh$>
    | <>
    | <>
    | | Subject: Re: Downloaded document has disappeared by the time Word has
    | opened
    | | Date: Thu, 1 Sep 2005 09:23:00 +0100
    | | Lines: 17
    | | X-Priority: 3
    | | X-MSMail-Priority: Normal
    | | X-Newsreader: Microsoft Outlook Express 6.00.3790.181
    | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
    | | Message-ID: <OW0#>
    | | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | | NNTP-Posting-Host: host217-45-2-106.in-addr.btopenworld.com 217.45.2.106
    | | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    | | Xref: TK2MSFTNGXA01.phx.gbl
    | microsoft.public.dotnet.framework.aspnet:121650
    | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | |
    | | > seems no other particular things except the content-type value.
    | Generally,
    | | > we can always use the "application/octet-stream" for all binary data
    | |
    | | Hi Steven,
    | |
    | | We originally had "application/octet-stream" in there but the problem we
    | | were having then on the test IIS 5 server was that the prompt to save
    | never
    | | appeared at all although it worked fine in the development environment.
    | |
    | | Anyone know of a good reference for HTML responses esp. these binary
    ones?
    | | The documentation in MSDN is very much at the reference level in
    | describing
    | | each of the methods/properties of Reponse.Cache, not necessarily what
    they
    | | are used for.
    | |
    | | Thanks, Rob
    | |
    | |
    | |
    |
    |
    Steven Cheng[MSFT], Sep 7, 2005
    #7
  8. > Have you got any further progress on this issue? If there're any further
    > things we can help, please feel free to post here. Thanks,


    Not yet - it's still an open job. One interesting point we noticed is that
    it behaves differently on the development PC to the pilot environment.

    Cheers, Rob.
    Rob Nicholson, Sep 7, 2005
    #8
  9. I'm sorry to hear that the problem remains. Also, since it's a environment
    specific problem , that really make the troubleshooting a bit difficult.
    have you also checked the IIS to see whether there're any custom headers
    set in the site or virtual dir's HttpHeaders setting, you can also compare
    your problem server with your development server. And here is the test code
    which works well on myside:

    private void DownloadFile()
    {
    Response.ClearHeaders();
    Response.ClearContent();

    Response.ContentType="application/octet-stream";

    Response.AddHeader("content-disposition", "attachment;
    filename=filename.ext");
    Response.WriteFile(@"full file path");
    Response.End();
    }

    You can also try testing it on your side. Hope helps.


    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    --------------------
    | From: "Rob Nicholson" <>
    | References: <uDvCh$>
    <>
    <>
    <OW0#>
    <>
    <Kkgyb#>
    | Subject: Re: Downloaded document has disappeared by the time Word has
    opened
    | Date: Wed, 7 Sep 2005 15:40:09 +0100
    | Lines: 9
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.3790.181
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: host217-45-2-106.in-addr.btopenworld.com 217.45.2.106
    | Path:
    TK2MSFTNGXA01.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!ne
    wsfeed1.ip.tiscali.net!news.maxwell.syr.edu!cyclone.bc.net!msrtrans!TK2MSFTN
    GP08.phx.gbl!tk2msftngp13.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:122889
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | > Have you got any further progress on this issue? If there're any further
    | > things we can help, please feel free to post here. Thanks,
    |
    | Not yet - it's still an open job. One interesting point we noticed is that
    | it behaves differently on the development PC to the pilot environment.
    |
    | Cheers, Rob.
    |
    |
    |
    Steven Cheng[MSFT], Sep 8, 2005
    #9
  10. Re: Downloaded document has disappeared by the time Word has opene

    Hi Steven,

    we have the same problem at our customers site with our application which
    provides display of ad-hoc generated thumbnails and download of photos or
    drawings after clicking on the thumbnails.

    First I compared the Internet Settings in IE from our customer with the
    settings at my computer. There is a Problem with the HTTP/1.0 compatibility
    mode. This means, when you un-check all options about HTTP/1.1 in IE settings
    no thumbnails are displayed and the downloaded bytes are 0 every time (e.g.
    the requested document opens in the corresponding application such as
    AutoCAD, Adobe Reader or Word, but then an error is displayed because there
    were 0 bytes transferred).

    We were able to reproduce this problem at our development site by
    un-checking all HTTP/1.1 options. So good, so far. I telled our customer to
    check the options, but with activated HTTP/1.1 support the error occurs... :(

    In the sourcecode we set following parameters:
    - ContentType to the correct Type by Extension of the corresponding file.
    - Content-Disposition
    - Content-Length

    Do you have an idea? ;-)
    Regards, Alex

    "Steven Cheng[MSFT]" wrote:

    > Hi Rob,
    >
    > Thanks for your response. I'm really feeling strange that the
    > "Application/octet-stream" not work on your product server. The
    > "application/octet-stream" just means normal binary stream and is used
    > when you didn't sure on the specific content-type or your custom stream.
    > This must be a environment specific problem. Also, have you tried testing
    > the page from some other client machines to see whether this is a client
    > specific problem? For the specification on HTTP request/response message or
    > content-type, cache ,setting, you can refer to the HTTP 1.1 rfc , but I
    > think the asp.net has completely encapsulated most of them so that we don't
    > need to care about the underlying details.
    >
    > Thanks,
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    =?Utf-8?B?QWxleGFuZGVyIEdyZWluZXI=?=, Dec 6, 2005
    #10
  11. Re: Downloaded document has disappeared by the time Word has opene

    Can't see th eorg. poster's msg.

    Add:
    Response.ClearHeaders()
    Response.ClearContents()

    Then add the desired headers


    "Alexander Greiner" <> schreef in
    bericht news:...
    > Hi Steven,
    >
    > we have the same problem at our customers site with our application which
    > provides display of ad-hoc generated thumbnails and download of photos or
    > drawings after clicking on the thumbnails.
    >
    > First I compared the Internet Settings in IE from our customer with the
    > settings at my computer. There is a Problem with the HTTP/1.0
    > compatibility
    > mode. This means, when you un-check all options about HTTP/1.1 in IE
    > settings
    > no thumbnails are displayed and the downloaded bytes are 0 every time
    > (e.g.
    > the requested document opens in the corresponding application such as
    > AutoCAD, Adobe Reader or Word, but then an error is displayed because
    > there
    > were 0 bytes transferred).
    >
    > We were able to reproduce this problem at our development site by
    > un-checking all HTTP/1.1 options. So good, so far. I telled our customer
    > to
    > check the options, but with activated HTTP/1.1 support the error occurs...
    > :(
    >
    > In the sourcecode we set following parameters:
    > - ContentType to the correct Type by Extension of the corresponding file.
    > - Content-Disposition
    > - Content-Length
    >
    > Do you have an idea? ;-)
    > Regards, Alex
    >
    > "Steven Cheng[MSFT]" wrote:
    >
    >> Hi Rob,
    >>
    >> Thanks for your response. I'm really feeling strange that the
    >> "Application/octet-stream" not work on your product server. The
    >> "application/octet-stream" just means normal binary stream and is used
    >> when you didn't sure on the specific content-type or your custom stream.
    >> This must be a environment specific problem. Also, have you tried testing
    >> the page from some other client machines to see whether this is a client
    >> specific problem? For the specification on HTTP request/response message
    >> or
    >> content-type, cache ,setting, you can refer to the HTTP 1.1 rfc , but I
    >> think the asp.net has completely encapsulated most of them so that we
    >> don't
    >> need to care about the underlying details.
    >>
    >> Thanks,
    >>
    >> Regards,
    >>
    >> Steven Cheng
    >> Microsoft Online Support
    Edwin Knoppert, Dec 6, 2005
    #11
  12. Re: Downloaded document has disappeared by the time Word has opene

    Here's our code snippet:

    string filename = System.IO.Path.GetFileName(_strFileSource);
    string mime = GetMIMEType(System.IO.Path.GetExtension(_strFileSource));
    System.IO.FileInfo file = new System.IO.FileInfo(_strFileSource);

    Response.ClearContent();
    Response.ClearHeaders();
    Response.ContentType = mime;
    Response.AddHeader("Content-Disposition","attachment; filename="+filename);
    Response.AppendHeader("Content-Length", file.Length.ToString());
    Response.Flush();
    Response.WriteFile(file.FullName);
    Response.Flush();

    We use Response.ClearContent() and Response.ClearHeaders() already, but in
    another order than your suggestion. Is this relevant to solve our problem? I
    mean, must I call ClearHeaders() before ClearContent()???

    "Edwin Knoppert" wrote:

    > Can't see th eorg. poster's msg.
    >
    > Add:
    > Response.ClearHeaders()
    > Response.ClearContents()
    >
    > Then add the desired headers
    >
    >
    > "Alexander Greiner" <> schreef in
    > bericht news:...
    > > Hi Steven,
    > >
    > > we have the same problem at our customers site with our application which
    > > provides display of ad-hoc generated thumbnails and download of photos or
    > > drawings after clicking on the thumbnails.
    > >
    > > First I compared the Internet Settings in IE from our customer with the
    > > settings at my computer. There is a Problem with the HTTP/1.0
    > > compatibility
    > > mode. This means, when you un-check all options about HTTP/1.1 in IE
    > > settings
    > > no thumbnails are displayed and the downloaded bytes are 0 every time
    > > (e.g.
    > > the requested document opens in the corresponding application such as
    > > AutoCAD, Adobe Reader or Word, but then an error is displayed because
    > > there
    > > were 0 bytes transferred).
    > >
    > > We were able to reproduce this problem at our development site by
    > > un-checking all HTTP/1.1 options. So good, so far. I telled our customer
    > > to
    > > check the options, but with activated HTTP/1.1 support the error occurs...
    > > :(
    > >
    > > In the sourcecode we set following parameters:
    > > - ContentType to the correct Type by Extension of the corresponding file.
    > > - Content-Disposition
    > > - Content-Length
    > >
    > > Do you have an idea? ;-)
    > > Regards, Alex
    > >
    > > "Steven Cheng[MSFT]" wrote:
    > >
    > >> Hi Rob,
    > >>
    > >> Thanks for your response. I'm really feeling strange that the
    > >> "Application/octet-stream" not work on your product server. The
    > >> "application/octet-stream" just means normal binary stream and is used
    > >> when you didn't sure on the specific content-type or your custom stream.
    > >> This must be a environment specific problem. Also, have you tried testing
    > >> the page from some other client machines to see whether this is a client
    > >> specific problem? For the specification on HTTP request/response message
    > >> or
    > >> content-type, cache ,setting, you can refer to the HTTP 1.1 rfc , but I
    > >> think the asp.net has completely encapsulated most of them so that we
    > >> don't
    > >> need to care about the underlying details.
    > >>
    > >> Thanks,
    > >>
    > >> Regards,
    > >>
    > >> Steven Cheng
    > >> Microsoft Online Support

    >
    >
    >
    =?Utf-8?B?QWxleGFuZGVyIEdyZWluZXI=?=, Dec 6, 2005
    #12
  13. Re: Downloaded document has disappeared by the time Word has opene

    Like i said, i was not able to read the orrg. msg from you.

    here is a fragment, the actual loop is after this code:
    ..Response.Clear()
    ..Response.ClearContent()
    ..Response.ClearHeaders()
    ..Response.ContentType = "inline"
    ..Response.AppendHeader("Content-Disposition", "attachment; filename=" &
    sFileNameOut)
    ..Response.AppendHeader("Content-Length", nTotalSize)
    ..Response.AppendHeader("Content-Transfer-Encoding", "BINARY")
    ..Response.Flush()

    (i have loop here)


    "Alexander Greiner" <> schreef in
    bericht news:...
    > Here's our code snippet:
    >
    > string filename = System.IO.Path.GetFileName(_strFileSource);
    > string mime = GetMIMEType(System.IO.Path.GetExtension(_strFileSource));
    > System.IO.FileInfo file = new System.IO.FileInfo(_strFileSource);
    >
    > Response.ClearContent();
    > Response.ClearHeaders();
    > Response.ContentType = mime;
    > Response.AddHeader("Content-Disposition","attachment;
    > filename="+filename);
    > Response.AppendHeader("Content-Length", file.Length.ToString());
    > Response.Flush();
    > Response.WriteFile(file.FullName);
    > Response.Flush();
    >
    > We use Response.ClearContent() and Response.ClearHeaders() already, but in
    > another order than your suggestion. Is this relevant to solve our problem?
    > I
    > mean, must I call ClearHeaders() before ClearContent()???
    >
    > "Edwin Knoppert" wrote:
    >
    >> Can't see th eorg. poster's msg.
    >>
    >> Add:
    >> Response.ClearHeaders()
    >> Response.ClearContents()
    >>
    >> Then add the desired headers
    >>
    >>
    >> "Alexander Greiner" <> schreef
    >> in
    >> bericht news:...
    >> > Hi Steven,
    >> >
    >> > we have the same problem at our customers site with our application
    >> > which
    >> > provides display of ad-hoc generated thumbnails and download of photos
    >> > or
    >> > drawings after clicking on the thumbnails.
    >> >
    >> > First I compared the Internet Settings in IE from our customer with the
    >> > settings at my computer. There is a Problem with the HTTP/1.0
    >> > compatibility
    >> > mode. This means, when you un-check all options about HTTP/1.1 in IE
    >> > settings
    >> > no thumbnails are displayed and the downloaded bytes are 0 every time
    >> > (e.g.
    >> > the requested document opens in the corresponding application such as
    >> > AutoCAD, Adobe Reader or Word, but then an error is displayed because
    >> > there
    >> > were 0 bytes transferred).
    >> >
    >> > We were able to reproduce this problem at our development site by
    >> > un-checking all HTTP/1.1 options. So good, so far. I telled our
    >> > customer
    >> > to
    >> > check the options, but with activated HTTP/1.1 support the error
    >> > occurs...
    >> > :(
    >> >
    >> > In the sourcecode we set following parameters:
    >> > - ContentType to the correct Type by Extension of the corresponding
    >> > file.
    >> > - Content-Disposition
    >> > - Content-Length
    >> >
    >> > Do you have an idea? ;-)
    >> > Regards, Alex
    >> >
    >> > "Steven Cheng[MSFT]" wrote:
    >> >
    >> >> Hi Rob,
    >> >>
    >> >> Thanks for your response. I'm really feeling strange that the
    >> >> "Application/octet-stream" not work on your product server. The
    >> >> "application/octet-stream" just means normal binary stream and is
    >> >> used
    >> >> when you didn't sure on the specific content-type or your custom
    >> >> stream.
    >> >> This must be a environment specific problem. Also, have you tried
    >> >> testing
    >> >> the page from some other client machines to see whether this is a
    >> >> client
    >> >> specific problem? For the specification on HTTP request/response
    >> >> message
    >> >> or
    >> >> content-type, cache ,setting, you can refer to the HTTP 1.1 rfc , but
    >> >> I
    >> >> think the asp.net has completely encapsulated most of them so that we
    >> >> don't
    >> >> need to care about the underlying details.
    >> >>
    >> >> Thanks,
    >> >>
    >> >> Regards,
    >> >>
    >> >> Steven Cheng
    >> >> Microsoft Online Support

    >>
    >>
    >>
    Edwin Knoppert, Dec 6, 2005
    #13
    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. =?Utf-8?B?QmFobWFu?=

    onclick postback event has disappeared

    =?Utf-8?B?QmFobWFu?=, Mar 2, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    583
    =?Utf-8?B?QmFobWFu?=
    Mar 3, 2006
  2. Replies:
    4
    Views:
    480
  3. srk
    Replies:
    0
    Views:
    619
  4. lichaoir
    Replies:
    3
    Views:
    430
    bruce barker
    Jul 18, 2008
  5. P. A.
    Replies:
    7
    Views:
    115
    Joel VanderWerf
    Sep 14, 2009
Loading...

Share This Page