title: Error when redirect page from Application_Error
body: <p>I'm trying to do a redirect, I have a singleton class that is my configuration class, picked up the information on this and ride my conectionString, this data I saved in an encrypted file, I am using session-per-request, then before mounting the my need to check for the session configurations file if there is not I throw the exception.</p>
  
  <pre><code> protected void Application_BeginRequest()
   {
      if (!Settings.Data.Valid())
         throw new SingletonException();
  
       var session = SessionManager.SessionFactory.OpenSession();
       if (!session.Transaction.IsActive)
          session.BeginTransaction(IsolationLevel.ReadCommitted);
  
       CurrentSessionContext.Bind(session);
   }
  </code></pre>
  
  <p>If there except I must redirect to the Settings page which is a singleton class.</p>
  
  <pre><code>protected void Application_Error(Object sender, EventArgs e)
  {
      Exception exc = Server.GetLastError();
      while (exc != null)
      {
          if (exc.GetType() == typeof(SingletonException))
          {
              Response.Redirect(@"~/Settings/Index");
          }
  
          exc = exc.InnerException;
      }
  }
  </code></pre>
  
  <p>However I am having a problem with this redirection, the link in the browser is changing but I'm having a redirect loop, already tried clearing the cookie and enable the option for external sites.
  <img src="https://i.stack.imgur.com/DkzeE.jpg" alt="enter image description here">
  Can someone help me?</p>