62,074
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
///LoginState 的摘要说明
/// </summary>
public class LoginState : IHttpModule
{
public void Dispose()
{}
public void Init(HttpApplication httpApp)
{
//session在这个事件管道应该是有效的吧???
httpApp.AcquireRequestState += new System.EventHandler(Verify);
}
public void Verify(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
//下面报错 System.NullReferenceException: 未将对象引用设置到对象的实例。
if (app.Context.Session["UserName"] == null)
{
HttpContext.Current.Response.Write("UserName is null");
}
}
}