|
Forums » .NET » ASP.NET »
Posted Date: 30 Jul 2012 Posted By:: rohit singh negi Member Level: Gold Member Rank: 856 Points: 5
Responses:
3
|
Hi ,
How to Extend Session Timeout through javascript?
string script = "window.setInterval(\"alert('Session has been idle over its time limit.Press any key now to conitnue session.');\", " + (Session.Timeout - 5) * 60000 + ")"; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "SessionManager", "<script language=\"javascript\">" + script + "</script>");
i using above code for given alert before session timeout but i need to increase session also.
Please help.
Thanks Rohit Negi
|
Responses
|
#682409 Author: Danasegarane.A Member Level: Gold Member Rank: 65 Date: 30/Jul/2012 Rating:  Points: 3 | The default session time values for asp.net Pages is 20 minute. If you want to increase the session time out value for particular website then you do this in the web.config file of the website
<configuration> <system.web> <sessionState mode="InProc" cookieless="true" timeout="40"/> </sessionState> </system.web> </configuration>
The above sets the session timeout to 40 minutes
Read the MSDN for more about session timeout http://msdn.microsoft.com/en-us/library/ms178581.aspx http://msdn.microsoft.com/en-us/library/h6bb9cz9%28v=vs.71%29.aspx
Thanks & Regards, Danasegarane Arunachalam
http://www.techreceipe.com/
| #682454 Author: Ajatshatru Upadhyay Member Level: Gold Member Rank: 19 Date: 30/Jul/2012 Rating:  Points: 4 | Hi,
You can handle it in JavaScript only through below code
<script type="text/javascript"> var sessionTimeout = 20; var remainingTime; remainingTime = setInterval('setRemainingTime()', 60000);
function setRemainingTime() { sessionTimeout--; if (sessionTimeout <= 5) { var result = confirm("You session is about to expire in " + sessionTimeout + " menutes! Press OK to increase session time"); if (result) { __doPostBack(); } } } </script>
In the above code, session timeout is set to 20 minutes. Before 5 minutes of session timeout, a confirm window is getting fired and if user clicks "OK" then the page is post backed using "__doPostback" so that session time can be initialized.
Hope it'll help you. Regards Ajatshatru
| #682502 Author: Paritosh Mohapatra Member Level: Diamond Member Rank: 6 Date: 30/Jul/2012 Rating:  Points: 4 | Add the following element in web.config:
<authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" timeout="144000"> </forms> </authentication>
If the application is hosted in IIS, then follow these steps:
1) Go to Control Panel -> Administrative Tools -> Inserter Information Services 2) Expand Default Web Site 3) Right Click on your Web Site -> Proerties 4) In the Web Site Properties dialog box go to ASP.Net tab 5) Click on Edit Configuration... button 6) In the ASP.Net Configuration Setting dialog box go ot State Management Tab 7) Increase the Session timeout (minutes)
Thanks & Regards Paritosh Mohapatra Microsoft MVP (ASP.Net/IIS) DotNetSpider MVM
|
|
| Post Reply |
|
|
|
You must Sign In to post a response.
|
|
|
|
 Follow us on Twitter: https://twitter.com/dotnetspider
|
|