Using Handler class
i have written following in the handler class to check the session satate.
public void ProcessRequest(HttpContext context)
{
if (context.Session["UserID"] == null || context.Session["ClientCode"] == null || context.Session["UserType"] == null)
开发者_StackOverflow {
context.Response.Redirect("~/LogIn.aspx");
}
}
now i need to make it affect on every .aspx page in my application how can i do it?
You'll either need an IHttpModule
for that, or subscribe to Application.BeginRequest
event somewhere in Global.asax
. Former is cleaner, but requires changes to Web.config
, latter is arguably less clean, but it's less code and doesn't require configuration changes.
精彩评论