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

  • SEARCH
  • Home
  • 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 280601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:07:57+00:00 2026-05-12T05:07:57+00:00

I was creating a http module and while debugging I noticed something which at

  • 0

I was creating a http module and while debugging I noticed something which at first (at least) seemed like weird behaviour.

When I set a breakpoint in the init method of the httpmodule I can see that the http module init method is being called several times even though I have only started up the website for debugging and made one single request (sometimes it is hit only 1 time, other times as many as 10 times).

I know that I should expect several instances of the HttpApplication to be running and for each the http modules will be created, but when I request a single page it should be handled by a single http application object and therefore only fire the events associated once, but still it fires the events several times for each request which makes no sense – other than it must have been added several times within that httpApplication – which means it is the same httpmodule init method which is being called every time and not a new http application being created each time it hits my break point (see my code example at the bottom etc.).

What could be going wrong here? Is it because I am debugging and set a breakpoint in the http module?

It have noticed that it seems that if I startup the website for debugging and quickly step over the breakpoint in the httpmodule it will only hit the init method once and the same goes for the eventhandler. If I instead let it hang at the breakpoint for a few seconds the init method is being called several times (seems like it depends on how long time I wait before stepping over the breakpoint). Maybe this could be some build in feature to make sure that the httpmodule is initialized and the http application can serve requests , but it also seems like something that could have catastrophic consequences.

This could seem logical, as it might be trying to finish the request and since I have set the break point it thinks something have gone wrong and try to call the init method again? Soo it can handle the request?

But is this what is happening and is everything fine (I am just guessing), or is it a real problem?

What I am specially concerned about is that if something makes it hang on the “production/live” server for a few seconds a lot of event handlers are added through the init and therefore each request to the page suddenly fires the eventhandler several times.

This behaviour could quickly bring any site down.

I have looked at the “original” .net code used for the httpmodules for formsauthentication and the rolemanagermodule, etc… But my code isn’t any different that those modules uses.

My code looks like this.

public void Init(HttpApplication app)
{
    if (CommunityAuthenticationIntegration.IsEnabled)
    {
        FormsAuthenticationModule formsAuthModule = (FormsAuthenticationModule) app.Modules["FormsAuthentication"];         

        formsAuthModule.Authenticate += new FormsAuthenticationEventHandler(this.OnAuthenticate);
    }
}

Here is an example how it is done in the RoleManagerModule from the .NET framework:

public void Init(HttpApplication app)
{
    if (Roles.Enabled)
    {
        app.PostAuthenticateRequest += new EventHandler(this.OnEnter);
        app.EndRequest += new EventHandler(this.OnLeave);
    }
}

Does anyone know what is going on?

(I just hope someone out there can tell me why this is happening and assure me that everything is perfectly fine) 🙂


UPDATE:

I have tried to narrow down the problem and so far I have found that the init method being called is always on a new object of my http module (contrary to what I thought before).

I seems that for the first request (when starting up the site) all of the HttpApplication objects being created and their modules are all trying to serve the first request and therefore all hit the eventhandler that is being added.
I can’t really figure out why this is happening.

If I request another page all the HttpApplication‘s created (and their modules) will again try to serve the request causing it to hit the eventhandler multiple times.

But it also seems that if I then jump back to the first page (or another one) only one HttpApplication will start to take care of the request and everything is as expected – as long as I don’t let it hang at a break point.

If I let it hang at a breakpoint it begins to create new HttpApplication‘s objects and starts adding HttpApplications (more than 1) to serve/handle the request (which is already in process of being served by the HttpApplication which is currently stopped at the breakpoint).

I guess or hope that it might be some intelligent “behind the scenes” way of helping to distribute and handle load and / or errors. But I have no clue.
I hope some out there can assure me that it is perfectly fine and how it is supposed to be?

  • 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-12T05:07:57+00:00Added an answer on May 12, 2026 at 5:07 am
    1. Inspect the HttpContext.Current.Request to see, for what request the module’s init is fired. Could be browser sending multiple request.

    2. If you are connected to IIS, do check IIS logs to know whether any request is received for the time you are staying at the break point.

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

Sidebar

Ask A Question

Stats

  • Questions 183k
  • Answers 183k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use: Alt+0 Alt+r - top of Window Alt+- Alt+r -… May 12, 2026 at 4:42 pm
  • Editorial Team
    Editorial Team added an answer In C-like languages, return exits the entire function. break will… May 12, 2026 at 4:42 pm
  • Editorial Team
    Editorial Team added an answer There isn't anything specific to Objective-C with an array of… May 12, 2026 at 4:42 pm

Related Questions

I have narrowed down my problem to the mysql_connect call I am doing in
I built subversion client (1.6.5) along with its required dependency libs on SuSe 10.
In an ASP.NET 2.0 website, I have a string representing some well-formed XML. I
Given: A C# calculation engine that loads an object model, crunches huge amounts of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.