session data missing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a asp.net 2/c# web database application which works fine, but
ocassionaly sesion data just dissapears. It's not any timeout as it happens
in the middle of work on it, and I just get 2 possible erros - obj ref not
set... cause the object in sesion no longers exists or it forwards users to
the log on page. as it happens frequently during the work it became a very
big problem, and I have no idea what could cause it.
pls help :)
 
I have a asp.net 2/c# web database application which works fine, but
ocassionaly sesion data just dissapears. It's not any timeout as it
happens
in the middle of work on it, and I just get 2 possible erros - obj ref not
set... cause the object in sesion no longers exists or it forwards users
to
the log on page. as it happens frequently during the work it became a very
big problem, and I have no idea what could cause it.

When it happens, does it happen for all users at the same time...?
 
Hi Nedim,

Session is lost if you are working on it (like compiling incase of Web
Application/ Changing Web.config etc). In otherwords once Application is
Restarted for any reason Session is lost.

You can work around this issue by using Out of Proc Session server
(aspnet_state.exe), then you can work freely.

Best Regards,
Parag
http://iparag.com
 
No, to some it happens to some not, but always at a different time for each
user.
And nobody touches the web server at that time - no web.config changes, iis
restars and similar stuff
 
No, to some it happens to some not, but always at a different time for
each
user.
And nobody touches the web server at that time - no web.config changes,
iis
restars and similar stuff

OK, so we can eliminate the app cycling since that would affect all users at
the same time...

Do you have any code which tears down a user's session by calling
Session.Abandon(), maybe when a user logs out...? Could this be being called
unexpectedly...?
 
No, there is no sign out code at all, as i have very stupid users, and they
exit via closing the browser (or just shutting down the computer).
 
No, there is no sign out code at all, as i have very stupid users, and
they
exit via closing the browser (or just shutting down the computer).

Starting to run out of ideas now...

Do you have any code at all which removes and/or modifies Session variables?

Are you using Forms Authentication?

Do you receive a notification of every error?

Can you discern any pattern to this?
 
well so far i couldn't see any pattern. i use forms authentification, below
is the web.config snippet. i receive notification when obj ref exception
occurs, but it doesnt help much. the only place where session data is being
written is after the login, when i put all the data regarding the logged on
user in a session object. after that i retrieve that data with
object UserData = System.Web.HttpContext.Current.Session["UserData"];

web.config:
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="Login.aspx"
defaultUrl="forme/home/Default.aspx" protection="All" timeout="60"
path="/"></forms>
</authentication>


and this it the code that creates the object in session (which we use later
on as static property, Korisnik is the name of the class in app_code)

public static Korisnik Trenutni
{
get
{
object oKorisnik =
System.Web.HttpContext.Current.Session["korisnik"];
if (oKorisnik != null)
return ((Korisnik)oKorisnik);
else
return null;
}
}
 
creates the object in session (which we use later on as static property

Whenever I see the words "session" and "static" in the same sentence, the
alarm bells immediately go off... :-)

Can you confirm that you are *not* creating static session variables...
 
The user variable is in session, the only thing is we access the object in
session through static variable.

public static Korisnik Current
{
get
{
object oKorisnik =
System.Web.HttpContext.Current.Session["korisnik"];
if (oKorisnik != null)
return ((Korisnik)oKorisnik);
else
return null;
}
}
 
Back
Top