1

Is there an event that I can tap into in Global.asax to execute some SQL in ADO.NET for logging every time a request is made to the application?

BuddyJoe
  • 69,735
  • 114
  • 291
  • 466

3 Answers3

3

Most of the time you would be able to get the information about the request in the IIS logs. You can use logparser which provides SQL like functionality to query what you want.

To add more information to IIS logs you can use Response.AppendToLog

To capture all request for an App, you can use Application_BeginRequest event of the Global.asax

Ramesh
  • 13,043
  • 3
  • 52
  • 88
  • How would you then ask for the fullpath of the page requested minus the server path? Then ask for the server name in a separate variable. Do I get at this through two of the ServerVariables? – BuddyJoe Mar 17 '10 at 20:52
  • 1
    In ASP.NET Request.Url.PathAndQuery will give full url - Domain name. Request.Url.Host - will give the host In IIS logs cs-uri-query - Will give the URI - Server cs-host - Will give the Domain name – Ramesh Mar 17 '10 at 20:59
1

There are better ways to do it, but call whatever you want in Begin_Request.

Specifically:

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
         //Do something at the beginning of every request.
    }
Ted
  • 7,122
  • 9
  • 50
  • 76
0

I think you need to investigate HttpModules (2) (3).

annakata
  • 74,572
  • 17
  • 113
  • 180
  • I was just trying to do a this.LogRequest += new EventHandler(global_asax_LogRequest); But then I get a "This operation requires IIS integrated pipeline mode." I assume the company I'm working at now is running some ASP.NET on IIS6 and some on IIS7. Thoughts? – BuddyJoe Mar 17 '10 at 20:47
  • Yeah - I've seen it before :) http://stackoverflow.com/questions/186548/iis6-httpmodule-this-operation-requires-iis-integrated-pipeline-mode – annakata Mar 17 '10 at 20:57