0

I am trying to implement session expire attribute using the link below:

Redirect at Session Timeout in Global.asax in mvc4

I have added the class and added the attribute to the controller method.

But it doesn't seem to trigger the attribute class once the session times out.

I know the session expires as I tried to implement Session_End in global.acsx file and it was expiring and entering the code.

web config:

<sessionState compressionEnabled="true" timeout="1" />
<authentication mode="Forms">
  <forms loginUrl="/Index" timeout="1" slidingExpiration="true" />
</authentication>

Any ideas on what i'm missing?

Community
  • 1
  • 1
tau
  • 288
  • 4
  • 19
  • Are you following same code explained [here](http://stackoverflow.com/a/6535159/1559213) – Murali Murugesan Mar 19 '14 at 10:32
  • No I was following this link, I tried the link you have posted but same thing. I was under the impression that when the session expires the class is called and then the method is run. But I think I have not understood this properly as how does the controller know when a session expires? – tau Mar 19 '14 at 10:53
  • http://stackoverflow.com/questions/21462167/redirect-at-session-timeout-in-global-asax-in-mvc4 – tau Mar 19 '14 at 10:54
  • You want to automatically redirect when session expires? Or you want to redirect when user does some action after session expired? – Murali Murugesan Mar 19 '14 at 11:02
  • redirect after session expires – tau Mar 19 '14 at 11:04

1 Answers1

0

That's not session its authentication cookie expiry time which you are setting.

Form Authentication cookie stores in .ASPXAUTH which has User Id, Name, token and Time property. to validate the use authentication

Session is Completely different . it stores in ASP.NET_SesionId which holds the dictionary object/container against the user on the server.

to set the time out on the session you need to set time out in session key in web.config

<sessionState mode="InProc" customProvider="DefaultSessionProvider" TimeOut="1">

this will expire your session object on the server in 1 min.

hope its make sense. for more information please google differnce between form auth and session.

regards

shaz

Community
  • 1
  • 1
Shazhad Ilyas
  • 1,183
  • 8
  • 14