1

I have a azure website which was running in browser. If I go to a particular page like my.azurewebsites.net/rest/api it's showing response on webpage. But if I used it in my PCL code like this

using (var httpClient = new HttpClient() { MaxResponseContentBufferSize = int.MaxValue })
{
     HttpResponseMessage response = await httpClient.GetAsync(url);
     response.EnsureSuccessStatusCode();
     return await response.Content.ReadAsStringAsync();
}

Than its showing inner exception "The remote name could not be resolved". Addition information; "An error occurred while sending request"

3 days before it was working fine. Now I don't know what happened and how to fix.

TheESJ
  • 2,357
  • 17
  • 13
mayank.karki
  • 750
  • 1
  • 9
  • 34
  • Are you sure that your browser does not have the response cached? – Nate May 12 '14 at 14:05
  • I tried it in other browser which I never used and its working fine. – mayank.karki May 12 '14 at 14:15
  • 1) What is the outer/main exception you are catching? (looks like you only documented the inner exception in your post) 2) Have you tried setting a user agent on `httpClient` -- I've seen requests denied to clients w/out user agent (not necessarily on Azure, just in general). – Nate May 12 '14 at 14:34
  • I think this is a problem with the code I am using. I tried using HttpWebRequest on windows 8 code and its working fine. I am using Ms.net.http nuget package for this. – mayank.karki May 12 '14 at 14:41
  • @Nate I tried using user agent like http://stackoverflow.com/questions/21441688/im-getting-403-with-httpclient-on-portable-class-library – mayank.karki May 12 '14 at 16:45
  • The nuget package just uses HttpWebRequest internally. Are you seeing the problem on Phone or Windows? Are you specifying the URL in the same way in both cases (HttpWebRequest and HttpClient)? – TheESJ May 13 '14 at 21:20
  • Does your application manifest specify that your application can use the internet/intranet? – bryanbcook May 13 '14 at 21:31

0 Answers0