locked
Custom HTTPModule Properties and Functions - How To Access? RRS feed

  • Question

  • User1457166430 posted

     

    1    class CustomHTTPModule : HTTPModule
    2    {
    3       // We will skip the Init() and other event functions
    4    
    5       private int _Count;
    6    
    7       public void OnBeginRequest(object s, EventArgs e)
    8       {
    9           /* If the page that is loaded or refreshed is the one we want to "trigger" this module, Manipulate _Count in this code, most
    10             likely just incrementing it until it is some finite
    11             value, most likely using multi-threading.
    12          */
    13      }
    14   
    15      public int GetCount()
    16      {
    17          return _Count;
    18      }
    19   }
    

    My understanding is that OnBeginRequest will get executed when a specific page (as we've done here) is refreshed or loaded. If it's executed, say, when the page loads, we know that _Count gets incremented. From where do we or can we call this HttpModule's GetCount() function? More specifically, we want to call this GetCount() function from JavaScript so that we can keep on calling it to allow us to display different _Count values. Is that even possible? What is the lifetime of _Count? Does it get reset when I reload the page again?

    Monday, April 27, 2009 12:45 PM

Answers

  • User-512273051 posted

    Hi,

    Why don't you put the Count in Session... now you ask .. how come I use session in HttpModule .. so here is the solution

    http://stackoverflow.com/questions/276355/can-i-access-session-state-from-an-httpmodule

    check it out.. by doing this you can use session in module and put your count in session

     

    cheers

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 27, 2009 4:07 PM