namespace WebApplication4 { public partial class _Default : System.Web.UI.Page {
public static bool UrlIsValid(string url)
{
bool br = false;
try
{
IPHostEntry ipHost = Dns.Resolve(url);
br = true;
}
catch (SocketException)
{
br = false;
}
return br;
}
private void Page_Load(object sender, EventArgs e)
{
string url = "http://www.srv123.com";
WebRequest wr = WebRequest.Create(url);
using (HttpWebResponse response = (HttpWebResponse)wr.GetResponse ()) { if (response.StatusCode == HttpStatusCode.OK) { response.Close();
Response.Redirect(url);
}
else
{
Response.Redirect("http://www.yahoo.com");
}
when i give google it redirects to google but when i giv an invalid url it doesn redirect to yahoo lik hw i hav given. i gave the response before redirect