IHttpHandler计算页面的执行时间


所属类别:编程

特别推荐:免费发布信息 承包关键词~~抢爆了!HOT!


来自Cuyahoga 使用自定义的PageHandler处理所有的aspx页面 获取页面的执行时间using System;using System.Web;using System.Web.UI;using System.Web.SessionState;namespace Cuyahoga.Web.HttpHandlers{ /// /// This class handles all aspx page requests for Cuyahoga. ///

public class PageHandler : IHttpHandler, IRequiresSessionState { #region IHttpHandler Members /// /// Process the aspx request. This means (eventually) rewriting the url and registering the page /// in the container. ///

///

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)); } /// /// ///

public bool IsReusable { get { return true; } } #endregion }}webconfig中注册HttpHandler

热门推荐:最全的Win XP系统找回密码技巧 Windows 2003必须进行的配置技巧【责任编辑 彭凡】

相关信息

· 一个萝卜一个坑 程序分配独立音量

· .NET WINFORM中使用本地SMTP SERVICE(CDO.Message错误处理)

· 显示器经典故障及其处理

·  51CTO独家报道:Windows 7加强电源管理








....

25730 76335