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. 

0
fazal
6/27/2008 10:22:26 AM
asp.net.state-management 8807 articles. 0 followers. Follow

3 Replies
1485 Views

Similar Articles

[PageSpeed] 24
Get it on Google Play
Get it on Apple App Store

You are saying right. Store static values during development like

    page_load 

        Session("variable")=value
 

 check some articles

http://www.codeproject.com/KB/session/Reconnect.aspx 

 

 

 


If this post was useful to you, please mark it as answer. Thank you!

Regards.
mimranshafiq
.NET Web Developer
http://www.dotnetclassic.com
0
M
6/27/2008 10:36:45 AM

fazal.shaikh:
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.

Hi Fazal,

Based on my understanding, you can modidy the web page’s code behind without losing session. However, if you change the codes in a separate class file, all the session objects are lost. If I have misunderstood anything, please let me know.

For this scenario, I would like to say it is the by design behavior. It is because modifying the class file will cause the application domain to recycle. However, ASP.NET will recompile the modified web page without recycling the application domain until 15 times (default value). It is the application domain’s recylce causes the session lost issue. For your reference, you can sess other conditions that can cause application domain to recycle.

ASP.NET Case Study: Lost session variables and appdomain recycles
http://blogs.msdn.com/tess/archive/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles.aspx

To persist session even ASP.NET process or applicatoin domain recycles, you may consider using “StateServer” or “SQLServer” session state mode to store session objects; then the application domain recycle will not result in session lost. For more information about session state mode, please refer to the following link:

Session-State Modes
http://msdn2.microsoft.com/en-us/library/ms178586.aspx

 


Sincerely,
Benson Yu
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
0
Benson
7/3/2008 2:25:03 AM

 Hi Benson,

Thanks a Lot for your Answer.

Best Regards,

Fazal. 

0
fazal
7/3/2008 6:45:11 AM
Reply:

Similar Artilces:

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)         {...

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

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

Using Session Variables inside a VB.Net Class File
I am developing an asp.net web site, using VB.Net as the core language, and have create a class file to store some global methods I use on a number of pages. When I try to implement a session variable inside a class in this manner:   Imports Microsoft.VisualBasic Namespace ChileNavy.global.SessionVars Public Class SessionVars Public Sub initializeVars() If Session("UserID") Is Nothing Then Session("UserID") = "SomeDefaultSetting" End If End Sub End Class End Namespace   I get an error "Session not declared". Suggesting that the class file sees this is a variable....

Session variables vs. Session States
What is the difference and in what situations are they used. Thanks, Mattypee A session state (the state of your session) holds your session variables. If your session state expires (due to inactivity) then you lose your session variables...and any other info stored for that session. If you need to store USER specific information within a web app, then session variables are one(of several) ways to do it. MajorCatsMajorCats Is there any code that you could show that would give an example? Thanks, Mattypee example of what? reading and writing session variables? ...

session variable cleared before session expires
I have web site developed in ASP.NET & c#. The problem is the session variables are cleared before the session expires. All the session variables are cleared before the session_end event fires. Please suggest probable reason for that. thanks Jog...

Session Variables Vs Session Class
Hi All, I am rewriting a classic ASP application in .NET using ASP.net and C#. We used Session Variables to handle storing the current user information throughout the original application.  I was wondering what the benefits would be of using a Session Class over Session Variables, and also how I could implement this? Many thanks in advance for any information you can give me. Regards, Aj Check this out. I think Session class always beneficial since you have more control over accessing and setting your session variables and exception handling. Check the link for its sample implem...

Getting Session ID and Session ID CHanging
I am building a cart, and when the user first accesses the site, I want to grab their SessionID. For some reason, I cannot get that Session ID when the site first pops up. I have a Session_Start() and Application_Start() function in the global.asax file. My other question is that everytime a page is loaded, a different session ID is grabbed and I am not sure why that would happen. Shouldn;t the Session ID always be the same while the user is on the site or the session timesout? Thanks If you don't use/store something in Session state during a user's Session, it will use a different ...

Session State Variables across multi sessions
I am having an issue where I save my DataTable into a Session Variable:   Session["dtDMFile"] = dtDMFile; Different users can use the web form that I created. Once the data is loaded,I send the DataTable to the session variable. My problem is that when I go to reload the data in the table, it is taking the data from the last user who stored the DataTable instead of from the particular user on their browser. For instance, User 1 (machine 1) loads data with field contents of: field1  field2  field3 User 2 (machine 2), then loads data with field contents of: f...

session variables getting changes
Hi,   I am having 2 frames in my page top_frameand middle_frame, the top frame has got a dropdown list, now i am calling a function in the selectedindexchanged to assign the text and value to two session variables when the user changes his selection in the dropdown list, now i also have an anchor tag close to the dropdownlist, when the user changes the selection in the dropdownlist the two session variables will be initialised and then the user clicks the anchor link and on the basis of the session variables the middle_frame page will  get changed..till this it is working properly...

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

Session State in a class file
I have a class that inherits system.web.ui.page. It is a class, not a web page. In this class, I am authenticating and authorizing the user on every page. If the user is not authorized, then then an exception is raised. I store that exception in session and transfer to an error page. My problem is that because this is not a literal web page, that the session object can not be used up front. It says that I must enable session state in the @page directory. Is there a way to set those programatically, or is there a way that I can grab the last exception raised from the error page...

Good news for those of you who get "Unable to make the session state request to the session state server." error..
Dear all,Due to the known problem of session variables getting lost if using InProc-server during frequent changes in development, I had to choose between SQL and ASP.NET State server, so I opted for the second. Initially, all fine, but after using it for a few days, I started to get this error: Server Error in '/cv2' Application.Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accep...

getting a new session id and losing session variables
prb: I have two pages in my app - one on redirect and the other as a new window - that get a new session id from every other page in the app (they both get the same session id) and obviously the session state variables are lost and, therefore, the pages do not look like they should.  All pages are within the same domain and virtual directory. 1. a redirect; session variables are lost; session id is different from the previous page; if you click the BACK button you return to the previous page and the session id is the same as before and the session variables are as they should be2. ...

Web resources about - My session variables get cleared session is alive when code is changed in the class files. - 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/17/2015 7:55:22 PM