【问题标题】:time-out asp.net gives error超时 asp.net 给出错误
【发布时间】:2013-04-29 22:13:56
【问题描述】:
当用户在网站上登录时,他可以做他想做的事情(这是正确的)。但如果他离开几分钟,就会发生某种time-out。这导致以下错误:
Object reference not set to an instance of an object.
他在显示用户名的会话中提出这个问题:
Label1.Text = "Welkom " + Session("Naam").ToString()
关于如何解决它的任何想法?或者如何正确显示?
【问题讨论】:
标签:
asp.net
session
timeout
【解决方案1】:
你有两个选择;
增加会话超时。因此,无论您在哪里创建会话,都可以设置超时时间。
Session.Timeout = 30;
或者在web.config中设置超时时间
<configuration>
<system.web>
<sessionState timeout="20"></sessionState>
</system.web>
</configuration>
或者您可以检查以确保会话值存在。
c#
if ( Session["Naam"] != null ){ ... }
vb.net
If Not Session("Naam") Is Nothing Then