title: How to detect Client Certificate Authentication request in HTTPWebRequest?
body: <p>I am using <code>HTTPWebRequest</code> to access a page which needs Client Certificate!</p>
  
  <p>I am using the following code and everything works!</p>
  
  <pre><code>    HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(textBox1.Text);
  
      X509Certificate2 userCert = SelectClientCertificate();
      if (userCert != null) myReq.ClientCertificates.Add(userCert);
  
      HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
  </code></pre>
  
  <p>Now here is my problem, since my call <code>SelectClientCertificate()</code> shows a Dialog to let the user select a Certificate, I don't want to show the Dialog if the Server doesn't ask for a Client Authentication! Actually I am looking for the behaviorism of Internet Explorer. If accessing a page for which the server needs a user client authentication, you get the Certificate select dialog shown otherwise not!</p>
  
  <p>I looked at the <code>AuthenticationManager</code> but I am not sure if I really need to register my own AuthenticationModule! so any hint for me?</p>
  
  <p>I also checked the the <code>StatusCode</code> for 403 or 403.7 but the server for now that I am working with, will also return 200 in case of missing Certificate, with content saying that I am not authorized!</p>