title: Session_Start firing multiple times on default ASP.NET MVC3 project
body: <p>I think I may have found a problem with ASP.NET MVC and it's event pipeline. In particular, I am finding that Session_Start is being called multiple times, each containing a new SessionID.</p>
  
  <p>Here's the step-by-step process:</p>
  
  <ol>
  <li>Open VS2010</li>
  <li>File | New Project</li>
  <li>ASP.NET MVC 3 Web Application, accept default name, click OK</li>
  <li>Select Internet Application (although I don't think it matters really), click OK</li>
  <li>When finished creating, edit the Global.asax.cs file</li>
  <li><p>Add the following method (yes it's empty):</p>
  
  <p>protected void Session_Start()
  {
  }</p></li>
  <li><p>Set a breakpoint in the method</p></li>
  <li>Debug</li>
  <li>Notice that the breakpoint is caught <strong>twice</strong> before displaying the page. If you watch "Session.SessionID" when the breakpoints are caught, you will see that the session id is new each time.</li>
  <li>Once you get to the home page, click on the "Home" or "About" tab link.</li>
  <li>Session_Start will be fired again, this time with a new SessionID.</li>
  <li>Continue execution, and any subsequent actions will no longer fire Session_Start.</li>
  </ol>
  
  <p>I tried the same thing on a standard ASP.NET Web Application (not MVC), and Session_Start only fired once.</p>
  
  <p>I'm pretty sure I'm not doing something wrong here, as I am using the default project templates, and the only code that is being modified is the Global.asax.cs file, to add the Session_Start method.</p>
  
  <p>I am using IIS Express, but I've repeated the above steps using the "Cassini" web server (Visual Studio Development Server), with the same result.</p>
  
  <p>Any advice?</p>
  
  <h2>UPDATE</h2>
  
  <p>I decided to use Fiddler to inspect the HTTP traffic during my debug session. It seems that:</p>
  
  <ol>
  <li>The first Session_Start is fired when I am requesting the "/" URL. This seems reasonable. The SessionID generated at that time is then written in the response to the browser. Again, seems reasonable.</li>
  <li>Fiddler then shows requests/responses for the *.js and *.css files. All successes. None of those fire off Session_Start. Good so far.</li>
  <li>Then Fiddler shows that a request has been made for "/favicon.ico". At this time, Session_Start fires, and generates a new SessionID... I continue.</li>
  <li>On Fiddler, it shows that the "/favicon.ico" file was not found (404). The webpage is displayed. I click on the "Home" link.</li>
  <li>The URL "/" is requested and response is OK in Fiddler. But then, another "/favicon.ico" file is requested, and again Session_Start fires with a new SessionID... I continue.</li>
  <li>All subsequent requests have responses, and the browser stops asking for "/favicon.ico".</li>
  </ol>
  
  <p>I made note of each of the three SessionID's generated, and it seems the one that the browser holds on to is the first one. So when we get to step 6 above, and everything seems to work, it's actually using the very first SessionID that was generated.</p>
  
  <p>So... I decided to host a "favicon.ico" file. I placed the ico file in the root of the project, and started my debug session again. This time, Session_Start only fires once. "/favicon.ico" was served successfully (200).</p>
  
  <p>So... I guess it is working the way it should in a sense... But why do calls to "/favicon.ico" fire off the Session_Start event???? Shouldn't I have the choice to NOT host a favicon?</p>
  
  <p>ASIDE: I tried all the above in an ASP.NET (not mvc) project, and it did not have the same problem, even though there was no favicon.ico file hosted by a default "ASP.NET Web Application" project.</p>