How to check whether the URL is valid or not

I have one textbox in that user enter the URL, but if want to check that URL while page rendering then what to do? Here is my code: protected void btnRender_Click(object sender, EventArgs e) { string strResult = string.Empty; WebResponse objResponse; WebRequest objRequest = System.Net.HttpWebRequest.Create(urltxt.Text); objResponse = objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { … Read more