开发者

Make Session expire

I am using authentication mode=forms in web.config file. Because it is a secure application so I want to ex开发者_C百科pire my session in 5 minutes. Right now I am doing it in programming in codebehind.

Is there any other easy way to do it?


You should do it in Web.config file. This will expire Session

<configuration>
  <system.web>
    <sessionState 
      mode="InProc"
      cookieless="true"
      timeout="5" />
  </system.web>
</configuration>

Other option is, This will expire cookie

<authentication mode="Forms">
   <forms name=".ASPXAUTH" loginUrl="Login.aspx" protection="All" timeout="5" path="/" slidingExpiration="true">
   </forms>
</authentication>


You can do it from c#

HttpContext.Current.Session.Timeout = 5;


See http://msdn.microsoft.com/en-us/library/1d3t3c61.aspx, there is timeout parameter.


Is this what you're looking for?

<system.web>
    <authentication mode="Forms">
          <forms timeout="5"/>
    </authentication>
</system.web>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜