I'm writing code to make HttpWebRequest to website
if website is working it will return HttpStatusCode.OK
if not it will return HttpStatusCode.NotFound
My code
var url = "http://simplegames.com.ua/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Debug.WriteLine("All ok");
}
else if (response.StatusCode == HttpStatusCode.NotFound)
{
Debug.WriteLine("URL not working");
}
response.Close();
But i have errors
1) Severity Code Description Project File Line Suppression State Error CS1061 'HttpWebRequest' does not contain a definition for 'GetResponse' and no extension method 'GetResponse' accepting a first argument of type 'HttpWebRequest' could be found (are you missing a using directive or an assembly reference?) Milano C:\Users\nemes\Documents\GitHub\Milano_pizza\Milano\MainPage.xaml.cs 50 Active
2) Severity Code Description Project File Line Suppression State Error CS1929 'HttpWebResponse' does not contain a definition for 'Close' and the best extension method overload 'ExtensionMethods.Close(Stream)' requires a receiver of type 'Stream' Milano C:\Users\nemes\Documents\GitHub\Milano_pizza\Milano\MainPage.xaml.cs 59 Active
HttpWebRequestin your code or namespace? - Jeremy HolovacsHttpClientinstead of anHttpWebRequestfor UWP, but I don't know if that will fix your problem. - Jeremy Holovacs