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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:37:37+00:00 2026-06-09T17:37:37+00:00

This is the download code: private string downloadContent() { WebRequest request = WebRequest.Create(url); request.Method

  • 0

This is the download code:

private string downloadContent()
        {
            WebRequest request = WebRequest.Create(url);
            request.Method = "GET";
            response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            reader = new StreamReader(stream);
            string content = reader.ReadToEnd();
            return content;
        }

The exception was on the line:

response = request.GetResponse();

This is the Exception:

system.Net.WebException was unhandled by user code
  Message=The remote server returned an error: (502) Bad Gateway.
  Source=System
  StackTrace:
       at System.Net.HttpWebRequest.GetResponse()
       at ChatrollLogger.Form1.downloadContent() in D:\C-Sharp\ChatrollLogger\ChatrollLogger\ChatrollLogger\Form1.cs:line 228
       at ChatrollLogger.Form1.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e) in D:\C-Sharp\ChatrollLogger\ChatrollLogger\ChatrollLogger\Form1.cs:line 112
       at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
       at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
  InnerException: 

What could be the problem ? Im downloading the ocntent from the site each n seconds.
Most of the times no problems so far i got this exception once only.

Line 112 is:

string content = downloadContent();

And line 228 is:

response = request.GetResponse();
  • 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-09T17:37:39+00:00Added an answer on June 9, 2026 at 5:37 pm

    (502) Bad Gateway could mean that the remote server is having trouble (site down, server being restarted etc)

    From http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html:

    10.5.3 502 Bad Gateway
    
    The server, while acting as a gateway or proxy, received an invalid response from the 
    upstream server it accessed in attempting to fulfill the request.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code (inside an AsyncTask) to download files: URL u =
I try to delete file after download file.My code is private void DownloadZipFileDialogue(string strZipFilePath)
I'm using the code below to download this XML file : private async static
I'm getting the links to the files using this code: private List<String> getFilesList(String path,
When I use this code to download this image (only used for testing purposes),
I have this code to download a file, but on sourceforge.net sever there is
When I have download sample code from this link and than try to build
With this code I can download the file but I should know the file
This is my code: if(resp.status > 0) { $('#download-stuff').html('<img src=/public/images/tick.png alt=Ready /> Your download
I start a download using PHP with this code: <? $_REQUEST['file'] = urldecode($_GET['file']); header(Content-type:

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.