<iframe marginwidth="0" marginheight="0" src="http://218.16.120.35:65001/PC/Global/images/b.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>
使用自定义的PageHandler处理所有的aspx页面 获取页面的执行时间
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
}
}
webconfig中注册HttpHandler
<httpHandlers>
<add verb="*" path="*.aspx"
type="Cuyahoga.Web.HttpHandlers.PageHandler,Cuyahoga.Web" />
</httpHandlers>
分享到:
相关推荐
在本文中,我们首先讨论了aspnet_...然后,我们通过三个实例,图片防盗链、图片验证码、处理自定义后缀名请求,详细讲解了IHttpHandler的实现方法和使用过程。 最后,我向大家概要地介绍了IHttpHandlerFactory接口。
IHttpHandler概述,请述关于IHttpHandler的原理
最简单的用IHttpHandler实现url重写,vs2005
在HttpHandler容器中,ASP.NET Framework才调用HttpHandler的ProcessRequest成员方法来对这个HTTP请求进行真正的处理,真正地对客户端请求的服务器页面做出编译和执行,并将处理过后的信息附加在HTTP请求信息流中...
可以使用作为验证码,不过要实现IRequestState接口
采用了一般处理程序(jquery+HttpHandler)实现数据查询、插入。分页控件采用SQL语句分页。
handler module factory的一个小demo
主要介绍了asp.net继承IHttpHandler接口实现给网站图片添加水印功能,实例分析了asp.net基于IHttpHandler接口实现网站图片水印功能的具体步骤与相关技巧,需要的朋友可以参考下
学习是使用asp.net已经有很长一段时间了,现在就来分析一下mvc的整过过程吧。个人计划写一个mvc系列的博文,仅从源代码的角度来分析mvc。在接触mvc时我们一定会经历路由,那么路由这东东是怎么搞出来的啊。在我们的...
【ASP.NET编程知识】asp.net继承IHttpHandler接口实现给网站图片添加水印功能实例.docx
Web开发不像软件开发,Web应用实际上是没有状态的,这就说明Web应用程序不自动指示序列中的请求是否来自相同的浏览器或客户端,也无法判断浏览器是否一直在浏览一个页面或者一个站点,也无法判断用户执行了哪个操作...
这是一个简单的上传文件的例子,例子中主要是上传图片格式的文件,只要把检查文件格式的代码删除,就可以上传其他格式的文件了.
代码如下: #region IHttpHandler 成员 bool IHttpHandler.IsReusable { get { return true; } } void IHttpHandler.ProcessRequest(HttpContext context) { string FileName = context.Server.MapPath(context....
指定的参数已超出有效值的范围参数名: utcDate 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及...1.可能是修改服务器系统时间所导致,更改服务器系统时间后,重新编译。
string url = context.Request.Url;... IHttpHandler handler = this.GetType().Assembly.CreateInstance(fullName) as IHttpHandler; //4.将 页面对象 存入 上下文中 context.MapHandler = handler;
public class Uploader : IHttpHandler { public void ProcessRequest (HttpContext hc) { foreach (string fileKey in hc.Request.Files) { HttpPostedFile file = hc.Request.Files[fileKey]; file.SaveAs...
现在的问题是,设置send.htm为起始页,页面还没加载完毕就运行到了后台。 应该怎样改才能,让点击页面按钮时才发送... 资源中Ajax,后台的IhttpHandler,都已经写好。希望Ajax高手能帮忙看一下,解决后200分酬谢~~