Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Session variables won't persist - Index was outside the bounds of the array

Posted on 2004-11-01
16
Medium Priority
?
1,095 Views
Last Modified: 2008-02-01
I've asked this before but it's really critical I solve this problem.  I have traced the error to the fact that the session variables loose their values after the browser has been idle for a couple of minutes.
I've tried playing with the web.config and adjusting the time there, but not luck.  I've tried several other things like putting this in the HTML display:
<body bgColor="#ffffff" MS_POSITIONING="GridLayout" onLoad="window.setTimeout(&quot;location.href='TimeoutMessage.aspx'&quot;,99999999)">
but I don't know if the 9's are miliseconds or seconds or minutes or if I've over done it and it reset to the default or what.
I've dont this as well:
            <script language="javascript">
            function renew()
            {
            alert(location.href);
            location.href=location.href;
            location.reload(true);
            }
            </script>

No luck.  Here is the error message.


Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[IndexOutOfRangeException: Index was outside the bounds of the array.]
   BlountOrder.plist.setUpEnvironment() +1786
   BlountOrder.plist.Page_Load(Object sender, EventArgs e) +10
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +750

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
0
Comment
Question by:dcass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
16 Comments
 
LVL 9

Expert Comment

by:Rodney Helsens
ID: 12464224
How have you concluded that session values are your problem? what is the code that is executing in this BlountOrder.plist.setUpEnvironment() method line +1786?

I'm sure you are already aware of the setting in web.config, which sets timeout to 20 minutes

   <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20" />
 
0
 

Author Comment

by:dcass
ID: 12464294
I'm sure about that the session variables have lost their value.  The web.config time-out is 20 minutes - I haven't timed it, it's not lasting 20 minutes.  I need to extend indefinitely.  Is there a limit? I have it set to 60,  and it's not working.
    <sessionState
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;user id=sa;password="
            cookieless="false"
            timeout="60"
    />
0
 
LVL 6

Expert Comment

by:ryerras
ID: 12464343
those are milliseconds in the setTimeout method. I can sense that your aspnet_wp process is getting recycled every now and then, thats the foremost reason for losing session prior to its timeout setting. aspnet_wp can recycle due to so many reasons, like modifying global.asax file, or modifying any file or content in the bin folder, or session timeout. Also make sure you are not changing session timeout settings anywhere, also try to access other session variables along with the one causing error, see if the entire session is gone or just that variable
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

by:dcass
ID: 12464407
It's the entire session.  
Can any of the code I'm using in the original question above cause this?
0
 
LVL 6

Expert Comment

by:ryerras
ID: 12464446
it could be so many reasons. I would suggest you build another test web app, and see if its happening the same with that application also. It should take only couple of minutes to build a test app
0
 

Author Comment

by:dcass
ID: 12464484
Yes, they all behave the same way on every server - mine, their test server and the live server.
I can't believe that everyone doesn't have this problem that uses session variables. and that there is not a simple solution.
I have the test server set to 60 and the live server set to 1000.  That's why I was asking if there was a limit and it's getting reset.
0
 
LVL 6

Expert Comment

by:ryerras
ID: 12464631
I am not really sure about the session timeout limit, but you should never keep the session timeout more than a reasonable amount. Remember we save so much stuff in session for each user, if we keep that session idling in the server memory, soon your server will runout of memory and more problems for you. THe best bet would be to look at the system event log to see the reason why aspnet_wp is recycling. So, please look at the event log and post the message here.

Again the following is from the msdn documentation why aspnet could be recycled

When using the in-process session-state mode, session-state data is lost if
aspnet_wp.exe or the application domain restarts. These restarts commonly
occur in the following circumstances:

##Setting an attribute in the <processModel> element of the application's
Web.config file that causes a new process to start when a condition is met,
such as memoryLimit.

##The Global.asax or Web.config file is modified.

##Changes to the \Bin directory of the Web application.

##Antivirus software scans and modifies the Global.asax file, the
Web.config file, or a file in the \Bin directory of the Web application.    
 
-------------------------------------------------------------
0
 
LVL 6

Expert Comment

by:ryerras
ID: 12464723
Take a look at this following link, it talks about a bug about aspnet_wp getting recycled due to deadlock

http://support.microsoft.com/default.aspx?scid=kb;EN-US;321792
0
 

Author Comment

by:dcass
ID: 12469815
Unfortunately, this patch is for 1.0.  We are developing in and running 1.1.
None of the other scenarios are possible.  It happens on the three systems plus my laptop that I work on (so 4 total).  Same code, same behavior.
We are all running different antivirus software and it shouldn't be changing any files, anyway.  We use trendmicro and panda - I'm sure they don't change code.
There is nothing in the event log about anything recycling or about aspnet at all.  How else would I be able to tell?
It is not machine specific - it must happen to everyone.  
The server has a lot of other .NET applications running.  Maybe it's picking up the wrong webconfig or something.  However, I sure it's loosing the values before the 20 minutes is up.  Is 1000 minutes over the limit?
0
 
LVL 6

Expert Comment

by:ryerras
ID: 12472090
when its timing out in less than 20 minutes, I dont see any point in increasing the timeout to 1000 minutes, and yeah it is considered to be too much, may be not over the limit. As I described before, if its not the aspnet recycling, you are resetting the timout period somewhere. You can try this. When session expires, it would call Session_End event in the Global.asax.cs. So try to do something in the event handler. Remember you can write anything from that event to the browser. Response object is not available to that event. I usually try this way, whenever there is a problem with session

Create an application variable, in application_start, then in the Session_Start event handler, try to append something to it (usually the current time), then in the session_End, remove that session variable. open some page which has session variables in two browser windows, leave one window idle, and keep the other window active, and keep experimenting with the timeout settings, and see at what timeout setting it is blowing up. This approach might look too confusing, but it is just to give you some idea, how the session works. Try experimenting with this and see, if its anything useful
0
 

Author Comment

by:dcass
ID: 12474733
That is the most practical advice I've had and I'll do this over the next couple of days.
However, what is the heirarchy of web.config's and how does the framework decide which one to use?
Will it always use the one compiled into the project or I thought I read somewhere that it could use a different one but can't remember the circumstances.
 
0
 
LVL 6

Accepted Solution

by:
ryerras earned 2000 total points
ID: 12474790
Your Machine.Config is the first config file every .NET application on your machine. Then your root's Web.Config will over ride the settings in the machine.config, then your sub directories config file will over ride your roots config file
0
 
LVL 6

Expert Comment

by:ryerras
ID: 12699368
There is only one participant in this question other than the original asker;). So I am also waiting for the askers decision
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question