本人在写一个过滤器,过滤一些不要的会员帐号...思想是这样的:
写一个实现IHttpModule的类..,然后在web.config在添加相关的代码..通过检测Session来实现
这个方法在aspx的页面里,可以正确实现我的要求..但在ashx类型的页面里,就报Session没值..
public void Init(HttpApplication application)
{ application.AcquireRequestState +=
(new EventHandler(this.Application_BeginRequest));
} private void Application_BeginRequest(Object source,
EventArgs e)
{ HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
HttpSessionState _Session = context.Session; if (_Session == null)
return; string username = _Session["username"] as string; //ashx的文件,提示这里有问题
context.Response.Write("<h1><font color=red>" + username +
"HelloWorldModule: Beginning of Request" +
"</font></h1><hr>");
}请问哪个大侠碰到过这种问题,谁能提供解决方法?
写一个实现IHttpModule的类..,然后在web.config在添加相关的代码..通过检测Session来实现
这个方法在aspx的页面里,可以正确实现我的要求..但在ashx类型的页面里,就报Session没值..
public void Init(HttpApplication application)
{ application.AcquireRequestState +=
(new EventHandler(this.Application_BeginRequest));
} private void Application_BeginRequest(Object source,
EventArgs e)
{ HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
HttpSessionState _Session = context.Session; if (_Session == null)
return; string username = _Session["username"] as string; //ashx的文件,提示这里有问题
context.Response.Write("<h1><font color=red>" + username +
"HelloWorldModule: Beginning of Request" +
"</font></h1><hr>");
}请问哪个大侠碰到过这种问题,谁能提供解决方法?
解决方案 »
- xss跨站脚本攻击思路
- ASP.NET+SQL Server+Session+购物车
- BS项目中Server.Transfer如何在系统中传递变量值?
- asp.net 博客的几个问题
- 在gridview里插入dropdownlist出现问题请大家火速解决!!!
- 不使用web.config,设置requestEncoding的编码方式为gb2312
- 求个好的方案。(关于datalist修改的问题)
- 帮我解释一下这两个方法的作用吧
- 高分求用ASP做的网络BBS ???
- 请问各位大侠,有没有针对域名的流量统计系统?
- VS2008 工具 选项 文本编辑器 里面为什么没有“所有语言”
- 【分享】大文件上传 进度条显示 (仿csdn资源上传效果)
终于给我找到了...在global.asax中加入这个
protected void Application_AcquireRequestState(object sender, EventArgs e)
在这里处理过滤,就可以了...狂晕...居然手册里都没提到这个