Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
751 views
in Technique[技术] by (71.8m points)

how to increase session timeout in asp.net?

I tried following codes to increase session timeout, but no use,

code is:

<sessionState mode="InProc" cookieless="true" timeout="60">
</sessionState>

Also code at

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Session.Timeout = 15;
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can increase the session time-out in asp.net in any one of the following ways

Using IIS Version 7 :

  1. Open up IIS
  2. Select your website from the list of sites
  3. Click on Session state on the right
  4. Now enter your session timeout under the cookie settings

OR

Web.config : Open up your web.config file and under the system.web section add the following :

<sessionState timeout = "20" mode = "InProc" />

Replace 20 with whatever number you wish.

OR

Global.asax file : Under the Session_Start method, set the timeout property of the session to the required value like this

Session.Timeout = "20";

Note : If you are setting a session timeout in both IIS as well as web.config, then the one in IIS will override the one in web.config

Hope this helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...