Click here to Skip to main content
15,900,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Suppose the user log in a website.
If user does not touch the keyboard and mouse for a certain time, then the session is destroyed for that user.
How can i do this using ASP.net(c#)
Please give me the answer
Posted

set session timeout property or used machine key in web.config
 
Share this answer
 
Comments
Mousumi2708 17-Dec-11 2:05am    
thanks ....but my question was if user does not interact with the browser for a given time interval suppose 10 mins. Then I want the page will redirected to the error.aspx page. If the user keep his interaction with the browser continuously then the session time out is not occurred. How can I do this .Please Give me the answer.
XML
<configuration>
  <sessionstate mode="inproc" timeout="20"/>
</configuration>



add this code in web config file within configuration tag

10000 is seconds
 
Share this answer
 
v3
Comments
Mousumi2708 17-Dec-11 2:05am    
thanks ....but my question was if user does not interact with the browser for a given time interval suppose 10 mins. Then I want the page will redirected to the error.aspx page. If the user keep his interaction with the browser continuously then the session time out is not occurred. How can I do this .Please Give me the answer.
go to this section in web.config file

<session-config>
    <session-timeout>30</session-timeout>
  </session-config>
 
Share this answer
 
v2
Comments
Mousumi2708 17-Dec-11 2:05am    
thanks ....but my question was if user does not interact with the browser for a given time interval suppose 10 mins. Then I want the page will redirected to the error.aspx page. If the user keep his interaction with the browser continuously then the session time out is not occurred. How can I do this .Please Give me the answer.
 
Share this answer
 
Just modify you web.config and set session timeout. It is minutes and default 20Min.
check following example.
XML
<system.web>
<sessionState timeout="60"></sessionState>
</system.web>

in above example session last for an hour that is 60min.
 
Share this answer
 
Comments
Mousumi2708 17-Dec-11 2:05am    
thanks ....but my question was if user does not interact with the browser for a given time interval suppose 10 mins. Then I want the page will redirected to the error.aspx page. If the user keep his interaction with the browser continuously then the session time out is not occurred. How can I do this .Please Give me the answer.
XML
<system.web>
<sessionState timeout="60"></sessionState>
</system.web>
 
Share this answer
 
In Global.asax,
find the code for Session_End
and write there
Response.Redirect("NameOfErrorPage");

and the timeout property of sessionstate in web.config will help you in maintaining the time period of time out
 
Share this answer
 
Comments
Mousumi2708 21-Dec-11 3:32am    
thnaks. It works
bolivankit 24-Dec-11 4:26am    
ur wc :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900