|
I made an http module today, I want to use him to judge, the login system is not,
I wrote it like this,
public class httpModuleSession: IHttpModule, IRequiresSessionState
{
public void Init (HttpApplication application)
{
application.AcquireRequestState + = (new EventHandler (this.Application_AcquireRequestState));
}
private void Application_AcquireRequestState (Object source, EventArgs e)
{
HttpApplication application = (HttpApplication) source;
HttpContext context = (HttpContext) application.Context;
string url = context.Request.Url.ToString (). Substring (context.Request.Url.ToString (). LastIndexOf ('/') + 1) .ToLower ();
if (url! = "login.aspx"&&context.Session ["UserInfo"]! = null)
{
context.Response.Redirect ("login.aspx");
}
}
public void Dispose ()
{
}
}
But it always reminds me that context.Session ["UserInfo"] does not exist. Excuse me, in which event can I capture the session? And if I write it like this
if (url! = "login.aspx")
{
context.Response.Redirect ("login.aspx");
}
So the picture in login.aspx doesn't show anything? Why not let me see it? |
|