Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

session data missing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nedim - 25 Oct 2007 08:54 GMT
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 :)
Mark Rae [MVP] - 25 Oct 2007 08:58 GMT
>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
[quoted text clipped - 4 lines]
> 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...?

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Nedim - 25 Oct 2007 11:53 GMT
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

> >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
[quoted text clipped - 6 lines]
>
> When it happens, does it happen for all users at the same time...?
Mark Rae [MVP] - 25 Oct 2007 12:16 GMT
>> >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
[quoted text clipped - 9 lines]
>>
>> When it happens, does it happen for all users at the same time...?

> 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...?

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Nedim - 25 Oct 2007 12:24 GMT
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).

> >> >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
[quoted text clipped - 23 lines]
> Session.Abandon(), maybe when a user logs out...? Could this be being called
> unexpectedly...?
Mark Rae [MVP] - 25 Oct 2007 12:41 GMT
>> 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).

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?

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Nedim - 25 Oct 2007 12:58 GMT
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;
       }
   }

> >> 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
[quoted text clipped - 14 lines]
>
> Can you discern any pattern to this?
Mark Rae [MVP] - 25 Oct 2007 13:28 GMT
> 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...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Nedim - 25 Oct 2007 19:09 GMT
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;
       }
   }

> > 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...
Parag C Mehta - 25 Oct 2007 09:07 GMT
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

> 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
[quoted text clipped - 3 lines]
> big problem, and I have no idea what could cause it.
> pls help :)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.