I need to intercept a web forms timeout event to trigger my own code.
How to do this?
What I have tried:
I have a website using Forms Authentication for user logins.
This is all working nicely but I want to include the ability to reject a logon if a user is already logged in. ie reject concurrent logons from 2 PC's.
To do this I have appended a 'LoggedIn' column to the SQL aspnet_Users table.
The asp:Login's 'LoginUser_LoggedIn' event writes a 1 to the LoggedIn column and further login attempts check this value before allowing access.
When the user logs off, the asp:LoginView's 'HeadLoginStatus_LoggedOut' event writes a 0 to the table to reverse the login.
As I said this is all working fine.
The problem I have is that when the forms automatic timeout is triggered, obviously the table is not updated to reflect the logout. I need to intercept the forms timeout event so as to update the users table.
How?
Here's the Forms code from the web.config file
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="~/Account/Login.aspx" protection="All" timeout="240" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="Default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false" />
</authentication>