DiederikEEn
DiederikEEn

Reputation: 743

time-out asp.net gives error

When a user loggs in on the website, he can do what ver he wants(Which is correct). But if he's away for a few minutes somekind of time-out happens. This is causing the following error:

Object reference not set to an instance of an object.

He thros this on the session which shows the username:

Label1.Text = "Welkom " + Session("Naam").ToString()

Any ideas on how to fix it? Or how to show it properly?

Upvotes: 0

Views: 445

Answers (1)

Tim B James
Tim B James

Reputation: 20364

You have two options;

Increase the Session timeout. So where ever you are creating the session, you can set the timeout.

Session.Timeout = 30;

Or set the timeout in the web.config

<configuration>
  <system.web>
     <sessionState timeout="20"></sessionState>
  </system.web>
</configuration>

Or you can check to make sure that the session value exists.

c#

if ( Session["Naam"] != null ){ ... }

vb.net

If Not Session("Naam") Is Nothing Then

Upvotes: 1

Related Questions