title: Attempt Windows Authorization but fall back on Custom Login
body: <p>I am working with a module that worked in previous versions of IIS.</p>
  
  <p><a href="http://www.velocityreviews.com/forums/t94333-re-how-do-i-create-a-httpmodule-to-authenticate-in-aspnet.html" rel="nofollow">http://www.velocityreviews.com/forums/t94333-re-how-do-i-create-a-httpmodule-to-authenticate-in-aspnet.html</a></p>
  
  <p>It no longer works because of the Integrated framework, and I cannot change it back to Classic.</p>
  
  <p>The need is for the client to attempt to access the web site and if they are a windows or domain user with access to the site, according to our database, they will be logged in automatically. If not they will be taken to the login page.</p>
  
  <p>The entire site is run off of the default.aspx page which is dynamically generated per call so we cannot have a separate login page.</p>
  
  <p>Does anyone know of a module or method to make this work in IIS 7/7.5?</p>
  
  <p>Edit:
  Below is the javascript that the module generates. It appears as though I always jump down to where I return
  location.replace("/default.aspx?abortScreening=true");</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Loading ...&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script type="text/javascript" language="javascript"&gt;
      function canAuthenticate() 
      { 
          try 
          {
          alert("Try canAuthenticate");
              var dom = new ActiveXObject("Msxml2.DOMDocument.4.0");
              dom.async = false;
              dom.load("CredentialsScreeningRequiresAuthentication.aspx?ReturnUrl=");
          }
          catch(e)
          {
              return false;
          }
      return true;
      }
      if (document.cookie.length != 0)
      {
          if (canAuthenticate())
          {
              location.reload();
          }
          else 
          { 
              location.replace("/default.aspx");
          }
      }
      else
      {
          location.replace("/default.aspx?abortScreening=true");
      }
  &lt;/script&gt;
  &lt;noscript&gt;
  "Your browser does not support JavaScript or has scripting disabled, which prevents credentials screening from working."
   Please click &lt;a href="/default.aspx?abortScreening=true"&gt;here&lt;/a&gt; to go to the requested page without authentication.
  &lt;/noscript&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>