Asp.net源码专业站
首页->新知实践->IP锁定程序实例源码>>MyHttpModule.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:IP锁定程序实例源码
当前文件:文件类型 BlockIP/MyHttpModule.cs[1K,2009-6-12 11:33:54]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Web; 5using System.Web.Security; 6using System.Web.UI; 7using System.Web.UI.WebControls; 8using System.Web.UI.WebControls.WebParts; 9using System.Web.UI.HtmlControls; 10using System.Collections; 11//该源码下载自www.51aspx.com(51aspx.com) 12 13namespace BlockIP 14{ 15 public class MyHttpModule : IHttpModule 16 { 17 public void Init(HttpApplication app) 18 { 19 //接收请求开始处理 20 app.BeginRequest += new EventHandler(app_BeginRequest); 21 } 22 23 void app_BeginRequest(object sender, EventArgs e) 24 { 25 Hashtable hash = (Hashtable)HttpContext.Current.Application["blockip"]; 26 if (hash != null && hash.Contains(HttpContext.Current.Request.UserHostAddress)) 27 { 28 HttpContext.Current.Response.Write("来源IP["+HttpContext.Current.Request.UserHostAddress.ToString()+"]不在允许访问之内<br><br>请与管理员联系解决!");//输出提示信息。 29 HttpContext.Current.Response.End();//终止请求。 30 } 31 else 32 { 33 HttpContext.Current.Response.Write("恭喜,你的IP不在受限访问51aspx之列!");//输出提示信息。 34 35 } 36 } 37 38 public void Dispose() { } 39 } 40} 41
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:IP锁定程序实例源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146