IHttpModule and Session State ???

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
8/4/2011 7:43:22 AM
Gravatar
Total Posts 101

IHttpModule and Session State ???

Hi All,

I have a custom IHttpModule which checks to see if a user is active on our intranet.

This is great and works well.

What I would like to do is also check the Session in the BeginRequest.... But it always comes back NULL.

What do I need to do so I can access Session values in the IHTTPModule ?

Any help greatly appreciated.

Regards
Andrew

PS. If the user is on a page I have some values Session["token"] for example that I would like
to check and react to in the BeginRequest.

 

        public void Init(HttpApplication application)
        {
            application.BeginRequest += new EventHandler(BeginRequest);
        }


        private void BeginRequest(object sender, EventArgs e)
        {
            HttpApplication app = ((HttpApplication)sender);
            HttpContext context = app.Context;
            string ip = SiteUtils.GetIP4Address();

            try
            {
                if (IsActiveUser(ip)) return;
            }
            catch (DbException ex)
            {
                log.Error("handled exception: ", ex);
            }
            catch (InvalidOperationException ex)
            {
                log.Error("handled exception: ", ex);
            }

            log.Info(string.Format("Attempting page redirect: {0} for {1}",loginPage,ip));
            context.RewritePath(loginPage);
        }


        private bool IsActiveUser(string ip)
        {
            // Check the ActiveUser Database and return True or False
            return db.ActiveUsers.Where(qry => qry.IpAddress.Equals(ip)).Count() > 0;
        }


        public void Dispose() { }

You must sign in to post in the forums. This thread is closed to new posts.