How can i make out whether the sitte requires authentication? RRS feed

  • Question

  • User-223588968 posted


    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.

    Friday, February 17, 2012 3:54 AM

All replies

  • User-425639139 posted

    try HttpStatusCode from the Request response like below:

    HttpWebResponse resp = (HttpWebResponse)rqst.GetResponse();
    HttpStatusCode respStatusCode = resp.StatusCode;
    Friday, February 17, 2012 6:49 AM
  • User-223588968 posted

    But the statuscode gives only the status of response..I mean the status like - server unavailable,OK,etc

    I get an OK response.

    Monday, February 20, 2012 12:47 AM
  • User-425639139 posted

    How about showing your Lines of Code here so I can analyze the issue.

    Monday, February 20, 2012 12:50 AM
  • User-223588968 posted


    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);

    Monday, February 20, 2012 7:45 AM