downloading file using writefile

Results 1 to 2 of 2

Thread: downloading file using writefile

  1. #1
    Join Date
    Dec 1969

    Default downloading file using writefile

    I&#039;m allowing web clients to be able to download a file, and then be redirected to another page. I&#039;m attempting to do this with the following code in c#.<BR><BR>Response.ContentType="Application/zip";<BR>Response.AddHeader("content-disposition","attachment; filename=file.pdf");<BR>Response.WriteFile("c:\fil e.PDF");<BR>//Response.Redirect("home.html");<BR><BR>The code above prompts the user to download the file, but after they download it, i want to redirect them to home.html. Problem is, if i uncomment the last line, then, this download page would get redirected to home.html, but IIS will not prompt user to download the file, in other words, the download process is skipped. Any response would be greatly appreciated.<BR><BR>Thanks,<BR>Gene

  2. #2
    Join Date
    Dec 1969

    Default It's a catch 22.

    To download the file, IIS has to send the browser particular headers.<BR><BR>To redirect the browser, IIS has to send OTHER headers.<BR><BR>Maybe you can do the redirect on the client-side via JavaScript or &#060;META&#062; tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts