1

i want to save some user settings on Session object. And get it from Session if i will need it. for this reason i want to create Base Controller which another controllers are inherited from this BaseController. and want to check the session for null. if session is null then redirect to logon page. i have added

<authentication mode="Forms">
      <forms loginUrl="~/Membership/LogOn" timeout="1" defaultUrl="~/Membership/LogOn" />
    </authentication>

to webconfig file. after minute it redirects to LogOn page. But i know that my session wil end after 10 minutes. how i can make so that Session objects and httpContext.Request.IsAuthenticated die in same time?

and please tell me in which Event i must check session in BaseController. in OnActionExecuting?

AEMLoviji
  • 3,217
  • 9
  • 37
  • 61
  • This has been asked [before](http://stackoverflow.com/questions/454616/asp-net-cookies-authentication-and-session-timeouts). But the accepted answer was just adding the data to the authentication ticket. Are you sure you could not simply do that...? – rsenna Dec 13 '10 at 15:48
  • it is not what i need. httpContext.Request.IsAuthenticated returns false but session not die yet. – AEMLoviji Dec 13 '10 at 15:58

1 Answers1

0

i did it. 1. I have created session on Global.asax file in Session_Start() event 2. i have configured IIS so that my session will expire after (5 minute) 3. and added this section to web.config file

  <authentication mode="Forms">
          <forms loginUrl="~/Membership/LogOn" timeout="5" defaultUrl="~/Membership/LogOn" />
    </authentication> 

and now httpContext.Request.IsAuthenticated will return false when session experied. because timeout both of them is 5 minutes

AEMLoviji
  • 3,217
  • 9
  • 37
  • 61