|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
September 13th, 2006, 09:48 AM
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Session variables being lost!
Hi all,
Has anyone ever heard of session variables just disappearing (equal to Nothing) like they'd never been defined?
I just did my first ASP.Net/ VB project, a small app on my company's intranet site. It works great for more than 100 users, but when you get to the app on one lady's laptop (regardless of who's logged onto the laptop) it fails. A little research reveals that all of the Session("variables") = Nothing... they're being lost between page displays. A couple of the session variables are strings, plus there's an integer, a datetime, a single, and a small dataset, and they're all Nothing. So when the code tries to use the vars, I get a NullReferenceException for the dataset object, or a nonexistent string being trying to be passed as an argument into a stored procedure. My code is converting the session vars to the appropriate type before use.
What I've checked:
It fails for me, too, when I plug my network cable into the lady's laptop, and log on as either myself and the user's login.
We only have one web server, not a server farm.
The laptop's internet and intranet setting's from Control Panel / Internet Options / Security tab are identical to my PC's, which works fine.
Another laptop purchased at the same time works fine.
It's apparently not a permissions issue... our Network Admin was using the app from his XP desktop, but when that machine was tied up with a download and he got to the internet from a Windows Server 2003 box, he got the error.
If anyone has any ideas, I'd appreciate it.
Thanks in advance...
LenexaKS
"The difference between genius and stupidity is that genius has its limits."
|
September 13th, 2006, 09:57 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
First, more then likely, a problem like this is going to be related to the server. (.NET is a server side technology and has little to do with the clients PC)
How are you storing session state? InProc, Cookieless, SQL Server? Is the session timing out? What is your session time out set to? Are these session variables as opposed to Application level variables?
"The one language all programmers understand is profanity."
|
September 13th, 2006, 01:33 PM
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for your reply.
I'm saving & retrieving session variables pretty vanillaly, like the following examples...
Session("Login") = UserLogin 'a string
'to retrieve it:
UserLogin = CStr(Session("Login"))
if UserLogin in Nothing Then '...error checking I had to add
Session("dsDestination") = dsDestination 'a dataset
'to retrieve it:
Dim dsDestination As DataSet = CType(Session("dsDestination"), DataSet)
If dsDestination Is Nothing Then '...error checking I had to add.
I'm not using cookies or application-level vars in this app anywhere.
In web.config, the "sessionState" items are:
mode="InProc"
stateConnectionString="tcpip=127.0.0.1: etc
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
It's just taking a very short time to bring up each page display, nothing like 4 or 5 seconds, much less 20.
Does that answer everything? If not, bear with me... I'm a newby at this.
Thanks again
|
September 13th, 2006, 01:56 PM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Why are you trying to store a Dataset in Session???? IMHO, you shouldn't do this and it may be where you are running into a problem.
When you store stuff in session, specifically when your session state is InProc, that information is stored on the server for the current client thread. (If you fire up task manager on the server the process is called aspnet_wp.exe) Anyway.
This process will can consumer up to 80% of your severs resources before it "recycles" itself and, what I mean by this, once that process has used up 80% of your system's resources, the process crashes and restart's itself. So what?
Since you are storing your session InProc, when this process crashes all of your current session data is lost (application wide) so, I think, that may be the problem you are running into since you said that this application is being used in a corporate environement and you have over 100 users hitting this application. (e.g. you are saving datasets in session which could be consuming a considerable amount or resources)
Lastly, to answer your question specifically, I have never run into an instance where my session variables just disappear and become null (the only time that I can forcibly make this happen, outside of letting my session timeout, is when i create a new build of my application in Visual Studio and then copy it over to my production directory, this causes the application to restart itself, thus my session info is lost)
"The one language all programmers understand is profanity."
|
September 14th, 2006, 12:47 AM
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
|
|
Sounds like a virus of some sort. Is it time to wipe clean and reload?
|
September 14th, 2006, 08:48 AM
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Dparsons,
The contents of the dataset is along the lines of 600-700 bytes of string info, and the instructor at the official MS ASP.Net course I just took said that it was ok to store small datasets. This app is a kind of fluff app to record employees' walking steps for a wellness program, so I'd think that most people would get in, click on the appropriate date, log their pedometer steps, and exit within a minute or two. ...so I didn't think that'd be too much of a resource hog. If I'm wrong, please tell me.
Also, this always happens, and (almost) only happens on this one laptop, even when I had it in my cube and was alternately trying different combinations of keystrokes in the app, on my pc and then on the laptop. My PC would always work great, and then 2 minutes later the laptop would always have Null session vars.
I did modify the program to reextract the dataset if it was Nothing, but then the program ran into the next session variable being Nothing a couple of steps down the road. I realize that I could store the info in a cookie, but since this isn't a vital app that I have to immediately fix, and since I'd like to know for future reference how to avoid or fix this, I haven't made that change yet.
BTW, in your opinion what's a ballpark figure for how big a cookie should get? The instructor and book weren't very definite.
Peace95, I didn't think that a virus could be the issue, because session variables are stored on the server.
Thanks for the info, and if I'm missing anybody's point please let me know.
|
September 14th, 2006, 09:05 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
What you store in the cookie is completely up to you, but whatever you store it can't be bigger then 4KB and you can not have more then 20 per server/domain (these are restrictions set as a standard on browsers).
While I do agree with your instructor, a dataset of that size isn't going to impact your server preformance (significantly) its a bad habit to pick up, simply by nature of it all.
You said "...this always happens, and (almost) only happens on this one laptop." What is the almost? Is this not isolated to just one PC?
Since this is a dataset, I assume there is a database that stores this information and why not if the Session value is null just repopulate the dataset and repopulate the session? What you may want to do is watch the server (if you have access to it) and see if the .net worker process is recycling itself. (Though your problem seems to be isolated to this one PC that it is unlikely, it never hurts to watch)
Outside of that, I am coming up with short with ideas since I have no point of reference on this whatsoever as I have never heard of such a thing.
"The one language all programmers understand is profanity."
|
September 14th, 2006, 02:17 PM
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You said "...this always happens, and (almost) only happens on this one laptop." What is the almost? Is this not isolated to just one PC?
>>> Our Network Admin was successfully using the app from his XP desktop, but when it was tied up he went to the site from a Windows Server 2003 box, and got the error. (I don't know if he remoted to it, or what.) This made me think that it wasn't a user setup / permissions problem.
Since this is a dataset, I assume there is a database that stores this information and why not if the Session value is null just repopulate the dataset and repopulate the session?
>>> I eventually did that, but then the next session var the program tried to use was also null for this laptop. I realize that could store the remaining fields in a cookie, but I'm just seeing if I can ferret out the cause, so that I don't have to code around this issue in the future.
Thanks
|
September 14th, 2006, 03:11 PM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
If you do figure this out I would be interested to know what the cause and solution of this situation was.
"The one language all programmers understand is profanity."
|
October 13th, 2006, 02:01 PM
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
A Help Desk guy figured it out in about 3 minutes... the PC had "Integrity Desktop" installed. ("Based on ZoneAlarm, the world's most trusted personal firewall, Integrity Desktop delivers preemptive protection against the latest worms, viruses, spyware, and hacker attacks.") This product has caused us a variety of minor web-related glitches in the past. A developer had told me to have the user check whether "ZoneAlarm" was installed, but in Add/Remove Programs it's now called "Integrity Desktop". Worked great after removing it and rebooting.
Thanks to all who responded...
|
|
|