I would like to check to see if URL given by the user is valid or not. Because if it is not, for example "http://www.stackoverflow" then it will crash the program later. I have tried to use the Web Response but it cannot find a definition for Irequest.GetResponse();
try
{
string url = HomepageTextBox.Text;
if (url != "")
{
WebRequest Irequest = WebRequest.Create(url);
WebResponse Iresponse = Irequest.GetResponse();
if (Iresponse != null)
{
}
}
else
{
HomepageTextBox.Text = "http://www.google.com";
}
}
catch (Exception ex)
{
MessageBox.Show("Invalid URL");
}
Thank you in advance :)
If you need any more details please comment and I will be happy to explain in further detail :)