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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:52:16+00:00 2026-05-26T21:52:16+00:00

I am using This code to download a file private WebClient client; client =

  • 0

I am using This code to download a file

      private WebClient client;    
        client = new WebClient();      
        if (isBusy)
        {
            client.CancelAsync();
            isBusy = false;
            this.downloadButton.Text = "Download";
        }
        else
        {
            try {
                Uri uri = new Uri(urlTextBox.Text);
                this.downloadProgressBar.Value = 0;
                client.Headers.Add("User-Agent: Other");
                client.DownloadFileAsync(uri, "test.csv.zip");         
                this.downloadButton.Text = "Cancel";
                isBusy = true;
            }
            catch (UriFormatException ex) {
                MessageBox.Show(ex.Message);
            }
        }

But I am getting an error the error is

  Download Not Complete: The remote server returned an error: (403) Forbidden.

I dont know why it is coming .

But when i use the uri for downloading in Free download Manager its working

I added this line

             client.Headers.Add("User-Agent: Other");

but its still not working.

There would be great appreciation if someone could help me.

Thanks In Advance.

  • 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-05-26T21:52:17+00:00Added an answer on May 26, 2026 at 9:52 pm

    It sounds like the free download manager you’re using might be spoofing the referer headers whereas your implementation is not. The server might be restricting downloads of the file you are attempting to download to only be downloadable if the referer field is set to a specific value (i.e. a site on the server). Have you attempted:

    client.Headers.Add("referer", uri);
    

    It might be worth using Fiddler to see the difference between the request the download manager sends and yours and then amend yours until it works.

    Edit:

    I’ve tested the URL you provided and I’ve got it working locally by adding the following:

    client.Headers.Add("Accept: text/html, application/xhtml+xml, */*");
    client.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
    

    You need to provide an “Accept” header otherwise the server does not know what your client wants / will accept. Here is my full anonimized sample application (using Sleep() for simplicity):

            string url = "http://..."; // Change this to the full url of the file you want to download 
            string filename = "downloadedfile.zip"; // Change this to the filename you want to save it as locally.
            WebClient client = new WebClient(); 
    
            try 
            {
                Uri uri = new Uri(url);
                client.Headers.Add("Accept: text/html, application/xhtml+xml, */*");
                client.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
                client.DownloadFileAsync(uri, filename);
    
                while (client.IsBusy)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            catch (UriFormatException ex) 
            {
                Console.WriteLine(ex.Message);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the code below to download this XML file : private async static
I am using this code: NSURLConnection *oConnection=[[NSURLConnection alloc] initWithRequest:oRequest delegate:self]; to download a file,
I have to download a file and I'm using this code , which is
I'm using this code to download a dynamic image file which is already on
I'm attempting to download a zip file using this code: o = urllib2.build_opener( urllib2.HTTPCookieProcessor()
I am using this code to download multiple file. My problem is that it
I'm using this code, to make a request to a given URL: private static
Right now I am using this code to download files (with a Range header).
In vb2005 how do you simulate a web browser's file download using Net.HttpListener? This
I am using ASP.NET to transmit a .jar file. This code works perfectly on

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.