Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6352935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:19:14+00:00 2026-05-24T22:19:14+00:00

I think I may have found a problem with ASP.NET MVC and it’s event

  • 0

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.

Here’s the step-by-step process:

  1. Open VS2010
  2. File | New Project
  3. ASP.NET MVC 3 Web Application, accept default name, click OK
  4. Select Internet Application (although I don’t think it matters really), click OK
  5. When finished creating, edit the Global.asax.cs file
  6. Add the following method (yes it’s empty):

    protected void Session_Start()
    {
    }

  7. Set a breakpoint in the method

  8. Debug
  9. Notice that the breakpoint is caught twice 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.
  10. Once you get to the home page, click on the “Home” or “About” tab link.
  11. Session_Start will be fired again, this time with a new SessionID.
  12. Continue execution, and any subsequent actions will no longer fire Session_Start.

I tried the same thing on a standard ASP.NET Web Application (not MVC), and Session_Start only fired once.

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.

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.

Any advice?

UPDATE

I decided to use Fiddler to inspect the HTTP traffic during my debug session. It seems that:

  1. 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.
  2. Fiddler then shows requests/responses for the *.js and *.css files. All successes. None of those fire off Session_Start. Good so far.
  3. 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.
  4. On Fiddler, it shows that the “/favicon.ico” file was not found (404). The webpage is displayed. I click on the “Home” link.
  5. 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.
  6. All subsequent requests have responses, and the browser stops asking for “/favicon.ico”.

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.

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).

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?

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:19:16+00:00Added an answer on May 24, 2026 at 10:19 pm

    I think I’ve come to a point where I have a couple of solutions (albeit both seem ‘hacky’ to me), so I think I’ll accept these and move on.

    Got a comment from @Tz_ above that mentioned I should ignore the route for the favicon file. That’s essentially what I’ll be doing. (kudos @Tz_!)

    Came across the following post, (among others). It describes a problem that when the browser requests a “/favicon.ico” file from an ASP.NET MVC site, the MVC stack is mistakingly trying to look for and instantiate a controller. I’m wasn’t sure if that was true or not for my situation, but the answer suggested adding the following route entry:

    routes.IgnoreRoute("favicon.ico");
    

    I gave it a shot (added the above), and that fixed it!

    So, I still don’t know why “/favicon.ico” request has a mistaken identity in MVC, but I know how to fix it in my situation. Either:

    • Host a favicon,
    • or add an ignore route entry.

    Again, both seem like hacks to me, as I think this is something controller factories should be capable of handling gracefully. IMHO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I may have found a bug in PHP's crypt() function under Windows.
EDIT: I believe i may have found the problem. I need to work on
I have a ASP.NET application that connects to a SQL server backend on another
As per another question I had asked earlier I think I may have found
Do you think it may be OK for a person to have more than
Sometimes it's difficult to describe some of the things that us programmers may think
We're developing quite a big application using ASP.NET MVC and at the beginning we
I have a question that may have been answered over 9000 times before but
please I have the same problem as I found here MySQL - Selecting data
I'm building an app in ASP.NET that will store some pictures of objects. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.