locked
Global page_request method? RRS feed

  • Question

  • User527605926 posted

    Hello, I'm trying to find out if there is some sort of global page_request method. I am writing some logging software for some old asp.net applications and I would like to include the new logging functionality in each page request. However, I do not want to have to recode every page. Ideally, I would like to add a single method that gets called before (or after) every single page request. I do not want to change the functionality of each page other than adding this logging functionality.

    Monday, August 24, 2009 3:19 PM

Answers

  • User187056398 posted

     You can use a global.asax file:

    <%@ Application Language="C#" %>
    
    <script RunAt="server">
          
        void Application_Start(object sender, EventArgs e)
        {
        }
        void Session_Start(object sender, EventArgs e)
        {
           
        }
        void Session_End(object sender, EventArgs e)
        {
           
        }
        
        void Application_BeginRequest(object sender, EventArgs e) 
        {
        }
        void Application_EndRequest(object sender, EventArgs e)
        {
    
        }
        void Application_End(object sender, EventArgs e)
        {
    
        }
        void Application_Error(object sender, EventArgs e)
        {
        }
    
    </script>
    
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 24, 2009 3:25 PM
  • User-809438689 posted

    How about writing custom HttpModule for logging? You will not have to modify your existing code and the same module can be reused across multiple projects, please refer this thread.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2009 2:00 AM

All replies

  • User187056398 posted

     You can use a global.asax file:

    <%@ Application Language="C#" %>
    
    <script RunAt="server">
          
        void Application_Start(object sender, EventArgs e)
        {
        }
        void Session_Start(object sender, EventArgs e)
        {
           
        }
        void Session_End(object sender, EventArgs e)
        {
           
        }
        
        void Application_BeginRequest(object sender, EventArgs e) 
        {
        }
        void Application_EndRequest(object sender, EventArgs e)
        {
    
        }
        void Application_End(object sender, EventArgs e)
        {
    
        }
        void Application_Error(object sender, EventArgs e)
        {
        }
    
    </script>
    
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 24, 2009 3:25 PM
  • User-809438689 posted

    How about writing custom HttpModule for logging? You will not have to modify your existing code and the same module can be reused across multiple projects, please refer this thread.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2009 2:00 AM