using System; using System.Web.SessionState; using System.Web; /// /// Summary description for LoggedInCheckerModule /// public class LoggedInCheckerModule : IHttpModule, IRequiresSessionState { #region IHttpModule Members public void Dispose() { } //public void Init(HttpApplication context) public void Init(HttpApplication app) { app.PreRequestHandlerExecute += new EventHandler(app_PreRequestHandlerExecute); } void app_PreRequestHandlerExecute(object sender, EventArgs e) { try { object username = null; string request = HttpContext.Current.Request.CurrentExecutionFilePath; try { username = HttpContext.Current.Session["username"]; } catch { } if (!request.ToLower().EndsWith(@"/default.aspx") && !request.ToLower().EndsWith("stylesheet.css") && !request.ToLower().EndsWith("topbanner_01.gif")) { if (username == null) { HttpContext.Current.Response.Redirect("Default.aspx"); } } } catch (Exception ex) { HttpContext.Current.Response.Redirect("Default.aspx"); } } #endregion }