title: ASP.NET SessionID In URL
body: <p>I'm taking over a ASP.NET web application that passes the session id in the URL string.  There is an odd bug that I have to assume has something to do with a server configuration but I'm at a loss. </p>
  
  <p>Page A has a URL string that looks pretty much like this:</p>
  
  <p><a href="http://whateverqa.com/NTapsWeb/(S(yn5cby55lgzstcen0ng2b4iq))/List_Forms.aspx?wid=__zzwid1" rel="nofollow noreferrer">http://whateverqa.com/NTapsWeb/(S(yn5cby55lgzstcen0ng2b4iq))/List_Forms.aspx?wid=__zzwid1</a></p>
  
  <p>when you click a button it goes to Page B that displays some information, when you click Exit on that page it takes you back to page A but notice how it moves the session id in the url back behind NTapsWeb:</p>
  
  <p><a href="http://whateverqa.com/(S(yn5cby55lgzstcen0ng2b4iq))/NTapsWeb/List_Forms.aspx?wid=__zzwid1" rel="nofollow noreferrer">http://whateverqa.com/(S(yn5cby55lgzstcen0ng2b4iq))/NTapsWeb/List_Forms.aspx?wid=__zzwid1</a></p>
  
  <p>This leaves me with a page error that says:</p>
  
  <p>"You are not authorized to view this page</p>
  
  <h2>You do not have permission to view this directory or page using the credentials that you supplied.</h2>
  
  <p>Please try the following:</p>
  
  <p>Contact the Web site administrator if you believe you should be able to view this directory or page. 
  Click the Refresh button to try again with different credentials. 
  HTTP Error 403 - Forbidden: Access is denied.
  Internet Information Services (IIS)</p>
  
  <hr>
  
  <p>Technical Information (for support personnel)</p>
  
  <p>Go to Microsoft Product Support Services and perform a title search for the words HTTP and 403. 
  Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled About Security, Authentication, and About Custom Error Messages."</p>
  
  <p>The strange thing is this is the way it works on the production server and it works just fine with the Session ID moving down in the string.  If I copy the session ID back up and put this in after the error:</p>
  
  <p><a href="http://whateverqa.com/NTapsWeb/(S(yn5cby55lgzstcen0ng2b4iq))/List_Forms.aspx?wid=__zzwid1" rel="nofollow noreferrer">http://whateverqa.com/NTapsWeb/(S(yn5cby55lgzstcen0ng2b4iq))/List_Forms.aspx?wid=__zzwid1</a></p>
  
  <p>it loads fine.  Again, this works fine in Production, just doesn't work on the QA server.</p>
  
  <hr>
  
  <p>Thanks for the response.  It's not a time out issue, because as I mentioned if I move the session ID up in the url it works again, so the data is still there.</p>
  
  <p>The code for the exit button is in JavaScript and it as follows:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function ExecFuncInMain(id, arg)
  {
      //alert('test'+id);
      var o = window.top._mainWindow.document.all[id];
      if(o!=null)
      {
          var s = o.onclick+"";
          //alert(s);
          if(s!=null &amp;&amp; s!='null') 
          {
              s = s.replace("javascript:", "").replace("\n", "").replace("\n", "").replace("\n", "").replace("\n", "").replace("\n", "").replace("{", "").replace("}","");
              s = "window.top._mainWindow."+s.replace("function anonymous()", "")+";";
          }
          else s = s.replace('null','');
          s = s+"window.top._mainWindow.__doPostBack('"+o.id+"', '');";
          //alert(s);
          eval(s);
      }
      else alert("object is null");
  }
  </code></pre>