2

I am trying a Windows 8 App which gets source code of a webpage and extract some important data. But I am receiving this when getStringAsync function get called.

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 173.194.41.64:443 at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)

Here is the code

const string feedUrl = "https://google.com";
HttpClient Client = new HttpClient();
Client.MaxResponseContentBufferSize = int.MaxValue;
Client.Timeout = System.TimeSpan.FromSeconds(300);
var source = await Client.GetStringAsync(feedUrl);
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
HannanKhan
  • 21
  • 1
  • Are you using any proxy for internet access?? – prashant thakre Aug 02 '14 at 17:54
  • NO, I am not using any proxy server. – HannanKhan Aug 02 '14 at 18:16
  • Try the below code , if its working it means you dant have any firewall or internet security issue,as its working fine for me. String feedUrl = "https://google.com"; HttpClient client = new HttpClient(); GetMethod method = new GetMethod(feedUrl); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); int statusCode = client.executeMethod(method); System.out.println(new String(method.getResponseBody())); – prashant thakre Aug 02 '14 at 18:38

0 Answers0