2013-07-31 33 views
0

我是新來的asp.net ..請幫助我編寫代碼來設置會話超時以及如何在所有頁面中實現,我嘗試了使用web配置方法,但沒有得到,我接近截止日期。 這是我的代碼 如何在asp.net中編寫會話超時

+0

哪裏是代碼,什麼d身份證你試試,你是什麼我和「但沒有得到」?你有沒有激活會話狀態?默認的超時時間爲20分鐘,所以您應該能夠讀取您在Session狀態下存儲的至少20分鐘的任何內容。如果你不能或者你的代碼是錯誤的,或者你根本沒有激活會話狀態。 –

+0

[ASP.NET中的會話超時]的可能重複(http://stackoverflow.com/questions/648992/session-timeout-in-asp-net) –

+0

在連接字符串中添加timeout = 2000。 – Janki

回答

2

從代碼:

Session.Timeout = 60; // this will set 60 min timout 

從配置:

<sessionState timeout="60" /> 
1

使用Web.config

<sessionState 
timeout="number of minutes"............ 

完全參考HERE

使用Forms authentication

<system.web> 
<authentication mode="Forms"> 
     <forms timeout="50"/> 
</authentication> 
<sessionState timeout="60" /> 
</system.web> 
+0

謝謝..但我有一個更多的懷疑...它會適用於所有頁面,我需要做aspx.cs頁面的任何編碼..請稍等 – user2637192