I am using httpwebrequest response to ping a site.That site is a secure site but when i ping i don get anauthentication error.I donot pass the password o r id still am able to check the status of site.
I want the user to see a "authentication required or credentials required " msg when the site is being pinged.
How can i do this
?
when i lookout for Authenticationlevel, i get MutualAuthentication value.
dipika.47
Member
12 Points
9 Posts
How can i make out whether the sitte requires authentication?
Feb 17, 2012 07:54 AM|LINK
Hi,
I am using httpwebrequest response to ping a site.That site is a secure site but when i ping i don get anauthentication error.I donot pass the password o r id still am able to check the status of site.
I want the user to see a "authentication required or credentials required " msg when the site is being pinged.
How can i do this
?
when i lookout for Authenticationlevel, i get MutualAuthentication value.
ankit.sri
Contributor
2048 Points
413 Posts
Re: How can i make out whether the sitte requires authentication?
Feb 17, 2012 10:49 AM|LINK
try HttpStatusCode from the Request response like below:
dipika.47
Member
12 Points
9 Posts
Re: How can i make out whether the sitte requires authentication?
Feb 20, 2012 04:47 AM|LINK
But the statuscode gives only the status of response..I mean the status like - server unavailable,OK,etc
I get an OK response.
ankit.sri
Contributor
2048 Points
413 Posts
Re: How can i make out whether the sitte requires authentication?
Feb 20, 2012 04:50 AM|LINK
How about showing your Lines of Code here so I can analyze the issue.
dipika.47
Member
12 Points
9 Posts
Re: How can i make out whether the sitte requires authentication?
Feb 20, 2012 11:45 AM|LINK
Hi,
This is code snippet that i use-
public void HttpReq() { HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(URL); myHttpWebRequest.Method = "GET"; myHttpWebRequest.AllowAutoRedirect = true; myHttpWebRequest.KeepAlive = false; HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); Stream streamResponse = myHttpWebResponse.GetResponseStream(); Console.WriteLine("Server has response : " + myHttpWebRequest.HaveResponse); Console.WriteLine("The Status Code is : " + myHttpWebResponse.StatusCode); }