Skip to content

Instantly share code, notes, and snippets.

@hishaamn
Created June 7, 2026 18:38
Show Gist options
  • Select an option

  • Save hishaamn/7c3a7cdea0bdff267f0ccd3c353c1c6b to your computer and use it in GitHub Desktop.

Select an option

Save hishaamn/7c3a7cdea0bdff267f0ccd3c353c1c6b to your computer and use it in GitHub Desktop.
private void SetAttachmentDisposition(HttpResponse response, string name, string extension)
{
    string filename = $"{name}.{extension}";
    string encoded = Uri.EscapeDataString(filename);
    response.Headers["Content-Disposition"] = $"attachment; filename=\"{filename}\"; filename*=UTF-8''{encoded}";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment