0

The following error started coming up suddenly! It worked for months after the application was deployed on the server but suddenly it has stopped working and showing the following error.

The code I am using as follows:

private void PostData()
{
  c.Add("publicid", "xxxxxxxxxxxxxxxxxxxxxx");
  c.Add("name", "ABC");
  c.Add("label:Affiliate_ID", "207");
  c.Add("website", "websitename.com");
  c.Add("label:IP_Address", Request.ServerVariables["REMOTE_ADDR"]);
  c.Add("firstname", txtFirstName.Text.Trim());
  c.Add("phone", txtPhone.Text.Trim());
  c.Add("lastname", txtLastName.Text.Trim());
  c.Add("email", txtEmail.Text.Trim());
  c.Add("label:Date_of_Birth", String.Format("{0:YYYY-MM-DD}", Convert.ToDateTime(txtDob.Text.Trim())));
  c.Add("lane", txtStreetAddress.Text.Trim());
  c.Add("code", txtZip.Text.Trim());
  c.Add("city", txtCity.Text.Trim());
  c.Add("Province", txtProvince.Text.Trim());
  c.Add("label:Time_At_Address", stay.ToString(CultureInfo.InvariantCulture));
  c.Add("label:Known_Credit_Issues", "yes");
  c.Add("label:Net_Monthly_Income", txtMothlyIncome.Text.Trim());
  c.Add("label:Occupation", txtOccopation.Text.Trim());
  c.Add("label:Employer_Name", txtEmployer.Text.Trim());
  c.Add("label:Employment_Length", "");
  c.Add("label:Bankruptcy", "No");
  c.Add("label:Employer_Phone_Number", "");
  c.Add("label:Employer_Postal_Code", "");
  c.Add("label:Employer_Province", "");
  c.Add("label:Employer_City", "");
  c.Add("label:Employer_Address", "");

  var myWebClient = new System.Net.WebClient();
  const string postingUrl = "https://xxxx.com/modules/Webforms/capture.php";

  byte[] responseArray = null;
  responseArray = myWebClient.UploadValues(postingUrl, "POST", c);
  var responseData = Encoding.ASCII.GetString(responseArray);
}

enter image description here

Please help! It is a live application :(

Thanks in advance.

Subrata Sarkar
  • 2,975
  • 6
  • 45
  • 85
  • download Fiddler which will help you see what is happening when you make your request - http://www.telerik.com/fiddler – Simon Price Aug 30 '15 at 06:14

1 Answers1

0

I'm going to take a shot in the dark and say that a system-wide proxy has been set on your server and since WebClient instances use that by default, it's now failing.

After:

var myWebClient = new System.Net.WebClient();

Add:

myWebClient.Proxy = null;

Recompile/restart the app and let me know if my voodoo debugging sense was right or utter BS.

Saeb Amini
  • 23,054
  • 9
  • 78
  • 76
  • Thanks for your quick reply. I added the fix and restarted the app. Now the page is taking too long to respond after I POST and finally ends up saying "The connection was reset" – Subrata Sarkar Aug 30 '15 at 06:50
  • @NiladriSarkar that means it's definitely proxy related, does the server use a proxy to communicate over the internet? check if that proxy is down. – Saeb Amini Aug 30 '15 at 07:10
  • I will put this to my client and let you know what he says. But thank you so much for the valuable information. At least now I can see some light – Subrata Sarkar Aug 30 '15 at 07:14
  • Got his response. He says there is no proxy set up on the server. – Subrata Sarkar Aug 30 '15 at 07:24