Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8169841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:58:30+00:00 2026-06-06T20:58:30+00:00

So it works with HttpResponse class: Response.AddHeader(Content-Disposition, attachment; filename=\ + fileName + \); (We

  • 0

So it works with HttpResponse class:

Response.AddHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");

(We have to encode file name for IE)
But now it should be done for HttpListener. It works for IE. The problem is FireFox and Chrome do not decode encoded header value like IE, but HttpResponse.AddHeader does not allow non-latin chars (code from System.Net):

if ((ch == '\x007f') || ((ch < ' ') && (ch != '\t')))
    throw new ArgumentException(SR.GetString("net_WebHeaderInvalidControlChars"), "value");

I tried to use Reflection to walk around the check:

Type type = response.Headers.GetType();
PropertyInfo info = type.GetProperty("InnerCollection",
    BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic);
NameValueCollection headers = (NameValueCollection)info.GetValue(response.Headers, null);
headers.Add(name, value);

Nothing is risen but the file’s name is totally corrupted.
What should I do to make it work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:58:33+00:00Added an answer on June 6, 2026 at 8:58 pm

    There is no portable and cross-browser way to do this.

    See a table at http://greenbytes.de/tech/tc2231/ for combinations of server/browser/headers that work and that don’t.

    Best bet is to send just Content-Disposition: attachment and let the browser to pick up the “default” file name from the /path/file.ext URI portion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

works: <form class=filter onsubmit=alert('submit');> <span class=a></span> <span class=b> <input type=text name=b /> </span> </form>
This works: require 'csv' file = CSV.open(filename) puts file.shift This does not: require 'csv'
Does Django flattening response after process_response? I have this model (simplified version): class Ticket(models.Model):
works fine on the desktop with xampp but when i upload it to my
This works but for some reason the comma is missing. data gets inserted as
This works: <cfdirectory action=list name=qry directory=C:\inetpub\wwwroot\Atlas\ > </cfdirectory> <cfdump var=#qry#> So I know that
This works when I have only one state code as a parameter. How can
I have the following module public class LowerCaseRequest : IHttpModule { public void Init(HttpApplication
I have an app that works fine. I'm trying to make one of the
I have a following class public class MyHttpClient { private static HttpClient httpClient =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.