Search code examples
c#http-headershttpresponsecontent-disposition

Alternative to Content-Disposition in HTTP Header (c#)


Is there an alternative for Content-Disposition with "attachment; filename=..."?

I'm sending a streamed on the fly exe file and wish the browser to open the "save as" or "run" when I begin sending.

I'm using the C# HttpResponseHeader and wish to use its members or the HttpWorkerRequest members.

Thanks, Moshe


Solution

  • Content-Disposition is the correct way to get the browser to prompt the user to save the file. Use HttpResponse.AppendHeader() to add the header value, eg:

    Response.AppendHeader("Content-Type", "...") 
    Response.AppendHeader("Content-Disposition", "attachment; filename=...")