473,699 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1732
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(ob ject sender, EventArgs e)
{
BeginRequestTim e = DateTime.Now;
}
private void application_End Request(object sender, EventArgs e)
{
HttpApplication application = (HttpApplicatio n)sender;

//Calculate elapsed time
PreSendContentT ime = DateTime.Now;
TimeSpan elapsedRequestT ime = PreSendContentT ime - BeginRequestTim e;

int elapsedMillisec onds =
Convert.ToInt32 (elapsedRequest Time.TotalMilli seconds);

application.Con text.Response.W rite("Elapsed Time: " +
elapsedMillisec onds.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
1745
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 to the developer? I want to be able to use page inheritance to create a centralized page controler without the need to build .aspx files for every page (since they would be pretty much empty shells anyway). Here is a sample of what I "want" to do....
8
5296
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 Response.ContentEncoding to the encoding of current content. Furthermore I set the Content-Type META tag of the html page to use the same charset as well. And this all works fine... I get my pages served and both the HTTP headers
1
988
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 so that I never have to worry about taking the time to load the rss feed at page load time? Thanks
7
4138
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 is how to corelate the response to a corresponding request. I am looking for a sure proof threadsafe way to corelate a response to a coresponding request message. Two things that concerns me:-
0
1115
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 of the implemented IHttpModule interface. I install the filter here. With the following statement: app.Request.Filter = new myFilter(app.Request.Filter);
3
9170
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 accessing machine.config, but I do not have access to the client machine.config machine. Therefore every request made from this application must have these proxy server settings. But I am having problems writing the code for this.
0
2874
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 is somewhat funny in that the server can send arbitrary requests to the client in the RESPONSES to calls to its webmethods)
7
4682
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: session = "Hello World"; When the request for that session variable "myString" is attempted to be retrieved, I would like to intercept that request like so: if (Request is for session variable "myString")
3
1768
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 filter uppercases every alphabetic character and then the second filter replaces every 'E' with "#'. OK, very nice. What's trivial about these examples is that the returned string is exactly the same length as the string which is actually read...
0
9034
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8883
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7750
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.