I am using the built in Forms authentication in an MVC3 application. The issue I am currently facing is that the cookies slidingexpiration is not working.
The web.config file has the following line:
<forms loginUrl="/auth" name="authy" path="/" slidingExpiration="true" />
note:: I have declared slidingexpiration even though the default is true.
Within my code I am making use of the basic Membership Provider class with no extending or modification. My global.asax file is using the system default.
There is no point in adding a code example as this is just a base project with no extra code added. I am using the FormsAuthentication.SetAuthCookie(username, true); to set the cookies initially.
Quote from the documentation:
2 very important things to notice in this quote:
You haven’t specified a timeout so the default value of 30 minutes will be used.
Another important thing to notice in this quote:
but I guess you don’t care about security since you have activated it.
UPDATE:
Here’s a full example illustrating the concept:
Controller:
View:
web.config:
No matter how long you stay on the Index view, the user will still be authenticated.