473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Creating a Request timer HttpModule

Hi,

We want to create a generic request timer that will inject the time it took
to render each page as a HttpModule. We want to be able to inject this just
before the finishing </body> tag but I can't seem to find a event to add an
handler for. The timer should start in BeginRequest and end after the code in
Render has been executed but then we don't have access to the controls
collection anymore (and I can't hook up to the render event using the context
in the HttpModule).

How can this be accomplished? Any links or hints are welcomed!

Thanks,
Manso
Jun 21 '06 #1
1 1717
Start your timer in the BeginRequest event as you stated. Then listen for the
EndRequest event. The handler for the EndRequest stops your timer and injects
the results into the Request just before it finishes.

Ex.

private void BeginRequest(object sender, EventArgs e)
{
BeginRequestTime = DateTime.Now;
}
private void application_EndRequest(object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;

//Calculate elapsed time
PreSendContentTime = DateTime.Now;
TimeSpan elapsedRequestTime = PreSendContentTime - BeginRequestTime;

int elapsedMilliseconds =
Convert.ToInt32(elapsedRequestTime.TotalMillisecon ds);

application.Context.Response.Write("Elapsed Time: " +
elapsedMilliseconds.ToString() );
}
--
-Demetri
"Manso" wrote:
Hi,

We want to create a generic request timer that will inject the time it took
to render each page as a HttpModule. We want to be able to inject this just
before the finishing </body> tag but I can't seem to find a event to add an
handler for. The timer should start in BeginRequest and end after the code in
Render has been executed but then we don't have access to the controls
collection anymore (and I can't hook up to the render event using the context
in the HttpModule).

How can this be accomplished? Any links or hints are welcomed!

Thanks,
Manso

Jun 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mslyh | last post by:
Is there a way to instantiate a page object in code and redirect the response to it? I know that this is how the actual ASP.NET engine ultimately does it under the covers. However, is this available...
8
by: Ricky K. Rasmussen | last post by:
Hello NG, I'm having some encoding trouble using my own RequestHandler: Since the RequestHandler must be able to serve content with diffrent encoding, I set the Response.Charset and...
1
by: Dustin II. | last post by:
Hi, I have a couple of rss feeds that are pulled into a datatable. I cache the datatable and use the cache to avoid long load times. Is there a way to do this caching in a timer on the server side...
7
by: Shapiro | last post by:
I have a scenario where I log a resquest to a database table and update the request with a corresponding response including the response time. I am using an HttpModule to do this. My challenge...
0
by: Tom | last post by:
Hi, I try to modify the request stream of the HttpApplication object. I work with a request filter, thus I implemented the Stream class at the derived class. In the BeginRequest event handler...
3
by: Codex Twin | last post by:
Hello apologies if this is the wrong newsgroup to be sending this to. Basically, I have an ASP.NET application that I am trying to force to use a proxy server settings. This can be done by...
0
by: mpdoreilly | last post by:
Hi, I've a webservice that has several typical webmethods that clients call and get responses from. (Side note: The websriivce is actually to implement the server side of tr-069, the protocol...
7
by: ADN | last post by:
Hi, I am creating a custom HTTPModule to intercept the request of when the user is attempting to retrieve a session variable. For instance, if I set a session variable in my code like so: ...
3
by: Joseph Geretz | last post by:
I'm using the Request Filter documentation which can be found here: http://msdn.microsoft.com/en-us/library/system.web.httprequest.filter.aspx In this example, two filters are installed, one...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.