In my asp.net website i am using asp.net form authentication with following configuration
<authentication mode="Forms">
<forms loginUrl="~/Pages/Common/Login.aspx"
defaultUrl="~/Pages/index.aspx"
protection="All"
timeout="30"
name="MyAuthCookie"
path="/"
requireSSL="false"
cookieless="UseDeviceProfile"
enableCrossAppRedirects="false" >
</forms>
</authentication>
I have following questions
What should be timeout value for session because i am using sliding expiration inside form authention due to which session will expire before form authentication. How can i protect it?
After formauthentication log out i would like to redirect page at logout.aspx but it is automatically redirect me at loginpage.aspx. How is it possible?
To achieve #2 you can manually check the cookie and its AuthenticationTicket for expiration and redirect to your custom page if they have expired.
You can do in it in one of the events: AcquireRequestState, AuthenticateRequest.
Sample code in the event can look like:
For sites that have a session dependency, you can simply sign out of a stale authentication with the session start event in the global.asax:
This makes it so that new session = new authentication, period.