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 8554907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:59:36+00:00 2026-06-11T14:59:36+00:00

I met today an issue, it is strange for me but, maybe, not for

  • 0

I met today an issue, it is strange for me but, maybe, not for experts in C# field.

I have a function called Download like this ( a piece of code !)

public void Download (string path){
  HttpContext.Current.Response.ContentType = "application/octet-stream";

  try {
           ....//process a 'filePath' variable using the 'path' parameter

               using ( FileStream sourceFile = new FileStream( filePath, FileMode.Open ) ) {
                 ...

                  HttpContext.Current.Response.AddHeader( "Content-Disposition", "attachment; filename=" + Path.GetFileName( filePath ) );

                  HttpContext.Current.Response.AddHeader( "Content-Length", fileSize.ToString() );

                  HttpContext.Current.Response.BinaryWrite( getContent );
               }
           ...

}

If file name mentioned and stored in path/filePath variable contains space like

PR SimpleTest.xls

then the download box contains file name like PR with nothing additional.

enter image description here

If that file name has NO space (like PR_SimpleTest.xls) then the header comes with PR_SimpleTest.xls and I can download as such (appears full filename with his extension).

There are solution(s) to solve issue in case when file name contains space(s) ?

  • 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-11T14:59:37+00:00Added an answer on June 11, 2026 at 2:59 pm

    A google search for http headers spaces finds this Knowledge Base article which suggests surrounding the filename with quotes. E.g.

    HttpContext.Current.Response.AddHeader(
        "Content-Disposition",
        "attachment; filename=\"" + Path.GetFileName( filePath ) + "\"");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I met an interesting issue about C#. I have code like below. List<Func<int>> actions
I met a problem like this. class A have a list of class B.
I have met this interesting problem today. I have a loop inside another loop
I'm applying UnitTest just for a while, and today I met something very strange.
I met strange problem. I have never work with Devise gem before. So, i
i met a very strange PHP behaviour, i don't understand why it behaves like
I met a problem with sum function: the data have a datetime column and
I met some compilation error but do not know what the problem is. The
I met trouble with a script I have done, this script should allocate an
I met strange difficulty developing one project. I dont have enough experience with classes

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.