<p>The single timing column in the weblog naturally includes client transmission timing.  For anamoly analysis, I want to differentiate pages that took excessive construction time from requests that simply had a slow client.</p>

<p>For buffered pages, I've looked at the ASP.NET page lifecycle model and do not see where I can tap in and codewise measure just the page-processing time before the page is flushed to the client.</p>

<p>I probably should have mentioned that my goal is production monitoring (not test or dev).  In addition, the intent is to annotate the weblogs with this measurement for later analysis.  Current we liberally annotate the weblogs with Response.AppendToLog().  I believe the desire to use Response.AppendToLog() somewhat limits my potential logpoints as for instance, the response-object is not viable in Application_EndRequest.</p>

<p>Any insight would be appreciated.</p>

[{'answer_id': 71569, 'author': 'Bob Dizzle', 'author_id': 9581, 'author_profile': 'https://Stackoverflow.com/users/9581', 'pm_score': 0, 'selected': False, 'text': '<p>the easist way would probably be to use the follow events in the global.asax file:</p>\n\n<p>protected void Application_BeginRequest(Object sender, EventArgs e)<br>\nprotected void Application_EndRequest(Object sender, EventArgs e)</p>\n\n<p>You could also implement a custom httpmodule</p>\n'}, {'answer_id': 71593, 'author': 'Kimoz', 'author_id': 7753, 'author_profile': 'https://Stackoverflow.com/users/7753', 'pm_score': 0, 'selected': False, 'text': '<p>This depends on the feature set of the performance tools you have. But if you just need to log the processing time then you could follow this approach.</p>\n\n<ol>\n<li>Log the starting time in the <a href="http://msdn.microsoft.com/en-us/library/system.web.httpapplication.beginrequest.aspx" rel="nofollow noreferrer">HttpApplication.BeginRequest</a> event.</li>\n<li>Log the elapsed time in the <a href="http://msdn.microsoft.com/en-us/library/system.web.httpapplication.presendrequestcontent.aspx" rel="nofollow noreferrer">HttpApplication.PreSendRequestContent</a> event.</li>\n</ol>\n\n<p>If you just want a specific page then you could check for this in the BeginRequest event.\nThe application events can be attached in Global.asax.</p>\n'}, {'answer_id': 71603, 'author': 'thomasb', 'author_id': 6776, 'author_profile': 'https://Stackoverflow.com/users/6776', 'pm_score': 0, 'selected': False, 'text': '<p>If you want to log on a specific page, I believe asp.net pages\' lifecycle begin with PreInit and end with Disposed, so you can log anything you want in those events.</p>\n\n<p>Or, if you want to log on every page, as Bob Dizzle pointed out, you can use the Global.asax file, which has a thousand events to choose from : <a href="http://msdn.microsoft.com/en-us/library/2027ewzw.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/2027ewzw.aspx</a></p>\n'}, {'answer_id': 71632, 'author': 'Timothy Khouri', 'author_id': 11917, 'author_profile': 'https://Stackoverflow.com/users/11917', 'pm_score': 2, 'selected': False, 'text': '<p>You could use a Stopwatch in the BeginRequest and the PreSendRequestContent as mentioned in the other two answers, or you could just use the request\'s Timestamp in the PreSendRequestContent.</p>\n\n<p>For example, on <a href="http://www.singingeels.com/" rel="nofollow noreferrer">SingingEels</a>, I added this to the bottom of my Master Page (yes, it\'s a hack) : <code>&lt;%=DateTime.Now.Subtract(HttpContext.Current.Timestamp).TotalSeconds %&gt;</code></p>\n\n<p>That way I can see how long any page took to actually execute on the server, including hitting the database, etc.</p>\n'}, {'answer_id': 72099, 'author': 'Joel Coehoorn', 'author_id': 3043, 'author_profile': 'https://Stackoverflow.com/users/3043', 'pm_score': 0, 'selected': False, 'text': '<p>You could also do your testing right there on the web server.  Then ClientTransmission time becomes effectively 0.</p>\n'}]
['https://Stackoverflow.com/questions/71306', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11791/']