0

I'm trying to check if website exists using:

private bool isExist(string url)
{
    WebRequest webRequest = HttpWebRequest.Create(url);
    webRequest.Method = "HEAD";
    try
    {
        using (WebResponse webResponse = webRequest.GetResponse())
        {
            return true;
        }
    }
    catch (WebException ex)
    {
        return false;
    }
}

It works on WPF, but on UWP doesn't have method GetResponse(). How to do it on UWP app?

Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
Tivyram
  • 111
  • 6

1 Answers1

2

You need to use the GetResponseAsync()

HttpWebResponse response = await webrequest.GetResponseAsync();
Md. Suman Kabir
  • 5,243
  • 5
  • 25
  • 43
Fuzzybear
  • 1,388
  • 2
  • 25
  • 42