Use ihttphandler to calculate the page execution time

Source: Internet
Author: User
Using System; Using System. Web; Using System. Web. UI; Using System. Web. sessionstate; Namespace Cuyahoga. Web. httphandlers { /// <Summary>      /// This class handles all ASPX page requests for Cuyahoga.      /// </Summary>      Public   Class Pagehandler: ihttphandler, irequiressessionstate { # Region ihttphandler members          /// <Summary>         /// Process the aspx request. This means (eventually) rewriting the URL and registering the page          /// In the container.          /// </Summary>          /// <Param name = "context"> </param>          Public   Void Processrequest (httpcontext context ){ String Rawurl = context. Request. rawurl; datetime starttime = datetime. now; // Obtain the handler for the current page              String Aspxpagepath = rawurl. substring (0, rawurl. indexof ( ". Aspx" ) + 5); ihttphandler handler = pageparser. getcompiledpageinstance (aspxpagepath, Null , Context ); // Process the page just like any other ASPX page Handler. processrequest (context); timespan duration = datetime. Now-starttime; context. response. Write (string. Format ( "Request finshed. Total duration: {0} ms ." , Duration. milliseconds ));} /// <Summary>          ///          /// </Summary>          Public   Bool Isreusable { Get {Return   True ;}} # Endregion }}

Register httphandler in webconfigCopy XMLCodeSave code

    httphandlers  >    Add   verb =   "*"   Path =   "*. aspx "  type =  " Cuyahoga. web. httphandlers. pagehandler, Cuyahoga. web " />     httphandlers    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.