05-05-2024, 07:08 AM
I've encountered an issue when attempting to perform an HttpWebRequest to a local WebService. The specific error that I'm running into is a `System.Net.WebException` with an inner `System.Net.Sockets.SocketException` stating that the connection was refused on localhost port 80. The application is attempting to make a POST request using the `WebRequest` class. But it seems like the target machine is actively refusing the connection. I've ensured that the service is up and running, and that my firewall settings allow for local connections. I thought initially it could be a problem with the SSL certificate, so I added a `TrustAllCertificatePolicy`, but the issue persists. Below is the snippet of code that is throwing the exception. Any insights on why this could be happening would be greatly appreciated.
Code:
}
}
} else {
request.ContentLength = 0;
}
response = (HttpWebResponse) request.GetResponse();