Response.Writefile problems on 2003 server

Discussion in 'ASP .Net' started by =?Utf-8?B?R2F2?=, Jul 27, 2007.

  1. Hi all,

    I'm trying to force downloads from my page specifically for some powerpoint
    and jpeg files. using the following code:

    Response.ContentType= "APPLICATION/OCTET-STREAM";
    string disHeader= "Attachment; Filename=\"" + sFileName + "\"";
    Response.AppendHeader("Content-Disposition", disHeader);
    System.IO.FileInfo fileToDownload= new System.IO.FileInfo(sDir + sFileName);
    Response.WriteFile(fileToDownload.FullName);
    Response.Flush();
    Response.Close();
    Response.End();

    My problem is that this works fine on the development (windows XP Pro)
    machine but when uploaded to production server (windows 2003 server) it
    doesn't work. On the 2003 server it downloads a file with the correct
    filename and extension but contains the webpage not the actual file
    information!! any ideas??

    Thanks
    Gav
    =?Utf-8?B?R2F2?=, Jul 27, 2007
    #1
    1. Advertising

  2. I think that you get exception somewhere between
    Response.ContentType line and Response.End

    Only that way I see how you can get an Html page.
    My bet would be on security exception trying to access file. Or "file not
    exists" exception


    George.


    "Gav" <> wrote in message
    news:...
    > Hi all,
    >
    > I'm trying to force downloads from my page specifically for some
    > powerpoint
    > and jpeg files. using the following code:
    >
    > Response.ContentType= "APPLICATION/OCTET-STREAM";
    > string disHeader= "Attachment; Filename=\"" + sFileName + "\"";
    > Response.AppendHeader("Content-Disposition", disHeader);
    > System.IO.FileInfo fileToDownload= new System.IO.FileInfo(sDir +
    > sFileName);
    > Response.WriteFile(fileToDownload.FullName);
    > Response.Flush();
    > Response.Close();
    > Response.End();
    >
    > My problem is that this works fine on the development (windows XP Pro)
    > machine but when uploaded to production server (windows 2003 server) it
    > doesn't work. On the 2003 server it downloads a file with the correct
    > filename and extension but contains the webpage not the actual file
    > information!! any ideas??
    >
    > Thanks
    > Gav
    George Ter-Saakov, Jul 27, 2007
    #2
    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. Jerry J
    Replies:
    2
    Views:
    761
    Jerry J
    Jul 20, 2003
  2. =?Utf-8?B?d2hvb3BkYWRkeQ==?=

    ASPX error using response.writefile -"the server reset the connect

    =?Utf-8?B?d2hvb3BkYWRkeQ==?=, Jul 19, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    2,402
    Steven Cheng[MSFT]
    Jul 27, 2004
  3. =?Utf-8?B?ZG90bmV0dGVzdGVy?=

    Response.writefile ....(file located on another server)

    =?Utf-8?B?ZG90bmV0dGVzdGVy?=, Jun 27, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,594
    =?Utf-8?B?ZG90bmV0dGVzdGVy?=
    Jun 27, 2005
  4. Ryan Pedersen
    Replies:
    1
    Views:
    2,190
    Daniel Fisher\(lennybacon\)
    Jul 12, 2005
  5. =?Utf-8?B?VmVsYXZhbg==?=

    Processing server side scripts using Response.WriteFile.

    =?Utf-8?B?VmVsYXZhbg==?=, Oct 3, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    384
    =?Utf-8?B?VmVsYXZhbg==?=
    Oct 3, 2005
Loading...

Share This Page