i have been trying to find out either provide URL is available or not. Available doesnt mean domain availability i mean either URL is accessible or its not accessible
i have tested code
var webrequest = (HttpWebRequest)WebRequest.Create(
"http://localhost:64519/TestPage.aspx");
webrequest.Method = "HEAD";
HttpWebResponse response = webrequest.GetResponse() as HttpWebResponse;
and there is some code on pageload of Testpage
protected void Page_Load(object sender, EventArgs e)
{
StreamReader stream = new StreamReader(Request.InputStream);
XDocument xmlInput = XDocument.Load(stream);
}
now issue is even i added HEAD in request yet it goes in to PageLoad and throws exception.
Scenario: i have been trying to send XML to provided URL. in XML case its working fine but when i try to check that either Link is live or not it throws exception because XDocument.Load(stream); dont have XML\ surely i can solve the issue by using
if (stream.BaseStream.Length != 0)
{
XDocument xmlInput = XDocument.Load(stream);
}
but its not appropriate. i just want to know the link is live or not based on my research is just Add headers but even with adding headers my problem is yet there
so please some one can help me out with this or any kind of help will be appreciated
StatusCodeof the response is 200?