Skip to content

Instantly share code, notes, and snippets.

@luanvuhlu
Created May 22, 2018 12:12
Show Gist options
  • Save luanvuhlu/5c9d53d1195ebe06c086b7b97f4c3afb to your computer and use it in GitHub Desktop.
Save luanvuhlu/5c9d53d1195ebe06c086b7b97f4c3afb to your computer and use it in GitHub Desktop.
string contentDisposition;
if (Request.Browser.Browser == "IE" && (Request.Browser.Version == "7.0" || Request.Browser.Version == "8.0"))
contentDisposition = "attachment; filename=" + Uri.EscapeDataString(fileName);
else if (Request.Browser.Browser == "Safari")
contentDisposition = "attachment; filename=" + fileName;
else
contentDisposition = "attachment; filename*=UTF-8''" + Uri.EscapeDataString(fileName);
Response.AddHeader("Content-Disposition", contentDisposition);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment