title: User Agent switching in the middle of a request?
body: <p>I have a really odd problem here - ASP.NET 3.5 Webforms app on IIS 6.</p>
  
  <p>The effect is that the user connects to our site, and gets an ASP.NET session, enters some data and suddenly, all his data entered (and stored in the session) is gone.</p>
  
  <p>Error logs shows us that for some odd reason, he's just getting a new session in the middle of working in our app.</p>
  
  <p>From the IIS logs, we see that <strong>within a single ASP.NET request</strong>, the user agent reported from the user's browser switches - from <code>MSIE+7.0</code> to <code>MSIE+8.0</code>.... how can that be? </p>
  
  <p>Excerpt from log:</p>
  
  <pre><code>07:06:38   GET /SomePage.aspx  80 - x.x.x.139   Mozilla/4.0+ (compatible;+MSIE+7.0;+Windows+NT+5.1)   401 
  07:06:38   GET /SomePage.aspx  80 DOMAIN\USERNAME  x.x.x.139  Mozilla/4.0+ (compatible;+MSIE+7.0;+Windows+NT+5.1)   200
  
  07:06:39   GET /javascript/somefile.js 80   DOMAIN\USERNAME x.x.x.139   Mozilla/4.0+ (compatible;+MSIE+8.0;+Windows+NT+5.1)  200 
  (lots more requests for .css, .js, .gif, .jpg - all with MSIE+8.0 ....)
  </code></pre>
  
  <p>It seems the two requests to the <code>.aspx</code> page are done in <code>MSIE+7.0</code> mode, while any subsequent requests for CSS and JS files as well as GIF und JPG graphics report back <code>MSIE+8.0</code> ...... WTF?!?!?</p>
  
  <p>Not sure if that really is the root cause of the sudden loss of ASP.NET session - but that user agent switching in itself leaves us scratching our heads.... any ideas?</p>
  
  <p>If this behavior is not the root cause of those "lost sessions" - any ideas / leads as to what could be the cause there? I haven't been able to dig up anything overly useful so far from here, Bing, Google or any other source....</p>
  
  <p><strong>Update:</strong> I read <a href="http://ellislab.com/forums/viewthread/121637/" rel="noreferrer">in this forum thread</a> that the fact the user agent is different between the first <code>GET</code> (which fetches the <code>.aspx</code> page) and the subsequent <code>GET</code> requests for the <code>.css</code>, <code>.js</code> could cause the session to be lost (this is a PHP environment, though). Can anyone confirm whether this applies to ASP.NET, too? (or show that this statement is not true)</p>
  
  <p>If this really is the case - is there any way to tell ASP.NET <strong>not</strong> to start a new sesssion just because the user agent string doesn't match the previous request?</p>