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?
+1
A:
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
2010-03-17 20:33:45
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?
tyndall
2010-03-17 20:47:37
Yeah - I've seen it before :) http://stackoverflow.com/questions/186548/iis6-httpmodule-this-operation-requires-iis-integrated-pipeline-mode
annakata
2010-03-17 20:57:56
+2
A:
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
2010-03-17 20:37:18
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?
tyndall
2010-03-17 20:52:12
In ASP.NETRequest.Url.PathAndQuery will give full url - Domain name.Request.Url.Host - will give the hostIn IIS logscs-uri-query - Will give the URI - Servercs-host - Will give the Domain name
Ramesh
2010-03-17 20:59:33