asp.net 4 form authentication: perform action on user session expiration

515 views Asked by At

I'm using "Forms" authentication in asp.net 4, with a fixed time before make the session expire.

I need to call a method that use some variables in Session just before logging out, but I am not able to handle the case when the user's session is expired (it just redirect me to the login page). For example, I would like to log something like "User session is expired!". Moreover, I need some info stored in Session.

I tried to use the Session_end method, but it seems that session expiration "event" does not trigger this function.

The configuration in web.config is:

<sessionState
    mode="InProc"
    cookieless="false"
    timeout="70"/>
    <authentication mode="Forms">
      <forms defaultUrl="~/Default.aspx"
          loginUrl="~/Login.aspx"
          slidingExpiration="true"
          timeout="1" />
    </authentication>
    <anonymousIdentification enabled="false" />
    <authorization>
      <deny users="?" />
    </authorization>

The 1-second delay for expiration is for debug purpose.

Is it possible to do what I need to?

Many thanks

1

There are 1 answers

1
jimmyc On

Think this may have already been answered.

Calling a method on Session Timeout?

Apologies if this is different.