session variable gets lost when calling a class

 Hi

I have a wierd problem that I am really struggling with

I have a session variable session("userid") that I use throughout a site with no problems

I am using a class to upload a file , the class is called on the on_click event of a button

when this class is called , the class works fine , does nothing unusual and does not use session variables , after the call to the class has done its thing the session("userid") is set to nothing ?

Does anyone know why this might be happening ? thanks

 

 

0
br3athe
6/28/2007 9:28:21 PM
asp.net.state-management 8807 articles. 0 followers. Follow

5 Replies
638 Views

Similar Articles

[PageSpeed] 57

How are you accessing the Session in the class? Make sure you are using HttpContext.Current.Session to access it. If you already are, or that doesn't work, post your code here so we can take a look at it.

 

-Aaron 


ASP.NET Weblog
http://weblogs.asp.net/aaronschnieder

Personal Blog
http://www.schnieds.com

My Business
http://www.churchofficeonline.com
0
Schnieds
6/28/2007 9:47:45 PM

can post some code, I can see what exactly u r doing


Raghu
(MCSD.NET, MCAD.NET, MCDBA)
[Don't forget to click on Mark as answer on the post that helped you ]
0
rmaiya
6/28/2007 9:49:47 PM

 hi

thanks for your quick response , I am not using the session in the class , however there was a conditional statement in the class

 if removefull=true then

Directory.Delete(Server.MapPath("../") & "uploads\eventoverseasfiles\blog\" & blogid & "\full\", True) 

 end if

 this problem with the session dissapearing was not happening in another instance when I call this class in the project

the *only* difference between the 2 calls was that removefull was true in the instance where the sessions dissapear

so I set removefull = false so directory.delete does not get called

the session variable now survives

to test I put this line in the code behind directly on the on_click event so simply

 

Directory.Delete(Server.MapPath("../") & "uploads\eventoverseasfiles\blog\" & blogid & "\full\", True)

 

and the session gets lost again

so the problem seems to be that deleting a directory is killing the session variables

I am glad I have found the problem *but* i do need to delete this directory at some point

do you know what this may be ?

thanks  

0
br3athe
6/28/2007 10:14:13 PM

HI,br3athe:

It sounds be caused by worker process (aspnet_wp.exe) recycles:

InProc - Session state will be lost if the worker process (aspnet_wp.exe) recycles, or if the appdomain restarts.  It's because session state is stored in the memory space of an appdomain.  The restart can be caused by the modification of certain config files such as web.config and machine.config,  or any change in the \bin directory (such as new DLL after you've recompiled the application using VS) For details, see KB324772. In v1, there is also a bug that will cause worker process to restart.  It's fixed in SP2 and in v1.1.  See KB321792.

If you're using IIS 6.0, you may want to go to IIS Manager, go to Application Pools/DefaultAppPool, and see if any of the parameters on the Recycling and Performance tabs are causing the IIS worker process (w3svc.exe) to shutdown.

For more details about app recycling, see my other FAQ: http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=232621

If i misunderstand you about your question, please feel free to correct me and i will try to help you with more information.


I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance


Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support

If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
0
Rex
7/2/2007 3:59:11 AM

hi

btw this problem was solved by using stateserver in web.config

 

  <sessionState mode="StateServer"
        stateConnectionString="tcpip=127.0.0.1:42424"
        cookieless="false"
        timeout="480"/>

you need to have the stateserver up and running which you can do in the services of you computer server - or ask your isp if its running 

0
br3athe
7/8/2007 7:00:14 PM
Reply:

Similar Artilces:

Loosing session state when I call a session variable from a derivated class
Hi folks I'm having an annoying problem. I have a web application which is used to edit some database data. The databases content may be in various languages, having one database for each language. I load a database calling it by the database name and the language suffix (for example: database_eng, when 'eng' is the laguage variable). So, I need to set a session variable 'Language', which is used in any webpage that calls information from a database. The problem I have is in some classes, which stores some methods to obtain information from databases. These clas...

My session variables get cleared session is alive when code is changed in the class files.
Dear Friends,I am working on visual studio 2005. I have written some forms which are using some classes. I keep on making changes in form code. Session variables retain their values. But when a minor change is done in the class file, session variables are cleared of where as the session is alive.Please help me in troubleshooting this.Thanks in advance.Best Regards,Fazal.  You are saying right. Store static values during development like    page_load         Session("variable")=value  check some articleshttp://www.co...

session variable gets lost
Hi! I have a session variable, and I set the Session.timeout=120; but after a while (not even 30 mins )it got lost and had errors cause of that in the app_code, where I have a function that takes as parameter the session variable value. Thank for any advice. Firstly make sure you are never overwriting the session variable.Another thing would be if the web server is low on resources it may drop some session items.  Make sure in the web.config file the session timeout is set properly     <sessionState timeout="120"/>Check below link for more info ht...

Session Variables getting lost
Hi I have a Parent Page called Parent.aspx in which i have a Grid View which has a column in which button is placed from which i am opening a Pop Up Window(Page) named Child.aspx. Before opening th pop up i assigning a DataTable to a Session variable so that i can access the DataTable in Child.aspx which can be accessed.Now I have created the 2nd DataTable in Parent.aspx for which the rows are added in the child.aspx page. The 2nd DataTable need to maintain all the rows which are added in child.aspx page. but unfortunately i am not getting  the DataTable from the Session .If i make...

Managing Session variables in a class
First, I am a newbee, very new and think i have gotten in trouble with this one. I want to create a class (i thought I did until i tried a second page) that can help me manage my session variables like session("userguid") through out the session for an individual. the thought was that there is a lot of information that continues to change and using a class if i set a value, it can automatically run code to do processing. So, for example, I have the following as my class: (short view of class) The name of this file is UserSession.vb Imports System.Data.SqlClient Public ...

After a looong night managed to change Session mode from inProc to SQLServer but still can't get the session variables to be saved
Hi,  I ran my Shopping Cart project and somehow everything worked fine(while in inProc), session variables were saved fine. I made some changes to my project and since then keep getting null session variables, no matter what I do. It took me the whole night to figure out how to turn to SQLServer mode,  marked custom classes as 'Serializable' with [Serializable] before the class definition but everything's in vain. Getting the same damned 'nulls' instead of the saved objects. private void Page_Load(object sender, System.EventArgs e)         {...

Session State Lost between 2 calls
Hi, I am building a Webservice with C#. I build my web service. There are 2 methods. The first one is Authenticate and the second one is to get the data from database based on the userid which is authenticated in the first method. In the client, I use C# to build a Windows Form application. I call the first method. After that, the server stored the user information by using Session object. I call the second method immediatially, but failed. I debug, I found that the user information I put into session in the first method lost. I did put [WebMethod(true)] attribute and I use url to acc...

ColdFusion Session Variables Getting Lost
Name: Randy Email: randyatgetsetdotcom Product: Firefox Release Candidate Summary: ColdFusion Session Variables Getting Lost Comments: I am a ColdFusion Programmer and just downloaded Firefox 3.0. Twice in the last twenty four hours my ColdFusion session variables have suddenly disappeared. It is possible they timed out. They have a two hour limit set but typically they persist two hours from last use it is possible they are timing out two hours from their creation. Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9) Gecko/2008051202 Firefox/3.0 ...

Session variable value gets lost
I am using asp.net 3.0 with C#. My web application requires some values that is used across my User Controls. These values are pertaining to the login user name and User type. When each user is logged in I store that username and user type in a session variable and whenever i need to used it like in a query I just called the string variable that is assigned to the Session variable. My problem is sometimes my session object/ string variable loses its value and I am wondering is there another way of storing my User's credential so that the value will not be lost until the User closes his/h...

Class members being lost in session state
Hey,     I'm sure this is something simple I'm not realizing has to be done for session state, but here is my problem.  I have a file class that has some general information and then it has a List(Of fileProperty) where fileProperty is another sub class.   Before this I was using List(Of Array List).  With the arraylist it went into the session state and came back out no problem.  But after switching array list to my own file property class the sub class of file property is being lost.  For instance the user will instantiate a file and ad...

Session state variable in class library
Hi guys,  How can I get hold of a session state variable in a class library (middle-tier), that is referenced by my web app? ThanksThe best glimpse of heaven is on the way into hell ;)yousef.omar@gmail.comhttp://nonstopbiztalk.blogspot.com You can get the current context to use it into the library HttpApplication.Context.Current.SessionCheersAlMy BlogMapStats.NETPlease click on 'Mark as Answer' if this post answered your question! First you will need to add a reference to the System.Web assembly. Once you've done that, you can access Session using: System.Web.HttpCon...

State management upon session variable changes
I noticed that whenever a session variable is changed...the application knows about it and suddenly restarts session. My question is does restart "ALL" sessions or only the active sessions for which the variables changed? Imagine a "multi-user" application all with different states and an administration panel that lets you change session variables.  In this case, my question has to do with the question that if Company X changes his session variables, will only Company X's sessions be reset or will all "sessions" be reset?  Hope that makes sense. ...

Session state keeps getting lost it seems....
I've had this problem for months it seems and I still haven't figured it out... I have a large, complex SQL-driven web application with 100 or so users. Every once in awhile users randomly get logged out and I think it's because the session is getting reset. I can't figure out why. I figured out one thing that was part of the problem. I was updating the system constantly, changing dozens of relatively large files at a time, and from what I read, if you do that too oftenASP will eventually run out of ram and reset itself, losing the session state. Apparently ASP doesn't get rid of the ...

Setting Session Variables from MasterPage...only want to call stored procedure once and set the Session Variables once
Using C#, VS2005, ASP.NET 2.0  I am getting a users Windows Identity and validating it against a database table for their UserID through a stored procedure. I am doing this through the Page_Init event from a MasterPage. I have tried using !IsPostback ,!Page.IsPostback, and !Master.Page.IsPostback to not have the Page_Init event called on every page. Is there somewhere or someway I can do this to only call the stored procedure once and set the session variables there? Kind of like a global variables (back in the VB6 days lol)...any help would be greatly appreciated.If you get an an...

Web resources about - session variable gets lost when calling a class - asp.net.state-management

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Expert Reveals the Latest Variable Capacity Technology
Learn about gForce Ultra CRAC equipment, the latest variable capacity technology to lower energy usage and increase reliability.

AD/CVD ruling and overseas capacity expansions are variables to the current PV boom, says EnergyTrend ...
China's National Reform and Development Commission has announced that there will be no significant reduction in feed-in tariff (FiT) rates for ...

Resources last updated: 12/25/2015 6:51:27 PM