IHttpHandler 系列一 入门篇
来源:互联网 发布:简单相册制作软件 编辑:程序博客网 时间:2024/06/02 16:12
using System.Web;
namespace Phone.HttpHandler
{
public class SimpleHandler : IHttpHandler
{
// Override the ProcessRequest method
public void ProcessRequest(HttpContext context)
{
//context.Response.Write("<H1>Hello, I'm an HTTP handler</H1>");
if( context.Request.UrlReferrer != null)
{
context.Response.Write("upurl:" + context.Request.UrlReferrer.ToString());
}
string _ip = context.Request.UserHostAddress; //获取IP
if(_ip=="")
{
context.Response.Write("对不起,您的IP:"+_ip+"已被限制!");
context.Response.End();
}
}
// Override the IsReusable property
public bool IsReusable
{
get { return true; }
}
}
}
以上就是一个简单的实现了IHttpHandler接口的处理程序,调用该程序的web 项目要添加该项目的引用,并在weg.config中加入如下配置:
<httpHandlers>
<add verb="POST,GET" path="*.aspxh" type="Phone.HttpHandler.SimpleHandler,Phone.HttpHandler" />
</httpHandlers>
verb处理的动作, path处理的文件类型,type=带命名空间的类路径,命名空间
注意一个web.config中只能有一个<httpHandlers>节点,不然会报错,但你可以在节点中添中多条记录
- IHttpHandler 系列一 入门篇
- IHttpHandler 系列二 应用篇
- IHttpHandler系列 (1)
- hibernate系列一:入门篇
- mybatis系列一:入门篇
- IHttpHandler
- IHttpHandler
- RxJava入门系列一,基础篇
- 机器学习入门科普篇--系列一
- Hibernate入门系列(一)
- IHttpModule 系列一 入门
- unity3D入门系列一
- DLL入门系列一
- kafka入门系列一
- Shiro入门系列一
- Latex--入门系列一
- nginx入门系列一
- WebGL入门系列一
- spring2.5-reference学习笔记
- MySQL errno: 150 Foreign Key Constraint
- PBDOM操作XML文档轻松入门(Easy XML with PowerBuilder Document Object Model)
- Ubuntu Linux下16款新手必备的超酷软件
- proxool连接池配置详解
- IHttpHandler 系列一 入门篇
- CSS opacity - 实现图片半透明效果
- MOBILE Starter (1) ---Error: The INF file contains Unicode characters that could not be converted correctly to ANSI
- 在Java SE环境下使用JPA1.0(Java EE 5.0 中的主要组成部分,TopLink配置
- 十年学会程序设计
- 从今天开始了!
- Flex/AIR 中 Embed 标签的使用
- 牛年好运!!
- "我不会"与"我要去学"