.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Crossing values of Session variables

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net

Hi all,

We are working in a web application using Session variables to store the clients ID to operate with them in all app (making orders, reports, etc....) but randomly users get the client ID of another user in any moment using the application.

I have tried to solve it in a first step adding to system.web section in the web.config file this:

<httpRuntime enableKernelOutputCache="false"/>

No changes after this. I have tried another possible solution, changing the SessionState to StateServer:

<sessionState timeout="30" mode="StateServer" stateConnectionString="tcpip="></sessionState>

ASP.NET State Service is running in server normally, It began run just before this last change, but we have not solved the problem either with this solution.

The server is Windows Server 2003 Standard Edition SP2 32bits running IIS 6.0, and the application is made with Framework 2.0

Are we doing wrong or forget something?


View Complete Post

More Related Resource Links

Session and Application Variables


I have a web application in which i need to logout the user if he clicks the logout button or even if he closes his browser window. On Logout button click, i am doing session.Abandon(), but how to go about his browser window close.

Can anybody help with a code sample.

How to store and retrieve multiple values in a single session variable .


I want to store employee name,designation and department in session variable and
retrieve in another page how to do this.

ASP.NET MVC 2 - I have a serious concern about the management of session variables.


I have a serious concern about the management of session variables.
I state that I have Windows Web Server 2008.
Currently values in the controller and call a session variable like this:
I have an action in as:
System.Web.HttpContext.Current.Session ['name'] = id_userlogged;

Defining session variables...



This is a pretty basic question.

I have some code where I need to define a session variable  however it's coming back as Nothing when the code is executed. Here's the code:

' Default Currency

REQCURR = Request.Querystring("p_DCURR")
'If not explicitly specified, try to get it from session

If (REQCURR = "") Then

     If (Session("REQCURR") <> "") Then
          REQCURR = Session("REQCURR")

          'Here is the session variable I'm trying to define:
          Session("REQCAD") = 0
          REQCURR = ""
     End If

End If


So, for some reason that Session("REQCAD") = 0 has no value instead of having a value of 0.

Any thoughts?


Need to access session variables in an ashx?

Dear All,In my project i need to set session in an ashx file and access that session in aspx.cs file. for this i am dooing the following things.In .ashx filepublic class Upload : IHttpHandler , System.Web.SessionState.IRequiresSessionState{    public void ProcessRequest(HttpContext context)    {            HttpPostedFile postedFile = context.Request.Files["Filedata"];            context.Session["img"] = postedFile.FileName;    }}After the file upload happand i wrote the code in .aspx.cs fileprotected void Button1_Click(object sender, EventArgs e)    {        Response.Write(Session["img"].ToString());    }this is working fine in IE but in Mozilla,Chrome,safari and Opera i got Session["img"] is null. Any help can be appreciatedThanks & Regards Basheer K M Cybrosys Technologies Pvt. Ltd. Calicut. http://www.cybrosys.com

Using Global.asax to Set Session Variables Pulled From SQLServer

I have a custom class that pulls user information from a SQL Server table. Now that I'm expanding the site from a single page to others. I want to shift the code to the Session_Start event so that the information is always loaded when the site is accessed. How do I call my custom code from global.asax since its script and not a class. 

pull values from session TList

I have populated a gridview with the following code string WhereClause = query; string OrderBY = "PostedOn desc"; int PageIndex = gvJobPosting.PageIndex; int PageSize = gvJobPosting.PageSize; int Count;   TList<JustClick.BLL.JobPosting> JobPosting; JobPosting = JustClick.DAL.DataRepository.JobPostingProvider.GetPaged(WhereClause, OrderBY, PageIndex, PageSize, out Count); Session["JobPosting"] = JobPosting; if (JobPosting.Count == 0) { errorMessage.Text = "There is no jobs available"; } else { gvJobPosting.DataSource = JobPosting; gvJobPosting.DataBind(); lblCurrentJob.Text = Count.ToString(); lblPostingsFound.Text = "job postings found."; btnExport.Visible = true; } and have a select button set to SelectedIndexChanged to pull all the details out and display in a formview i'm using the following code so far   protected void gvJobPosting_SelectedIndexChanged(Object sender, EventArgs e) { TList <JustClick.BLL.JobPosting> JobID; JobID = (TList<JustClick.BLL.JobPosting>)Session["JobPostings"]; int PostID = JobID[0].JobPostingID; TList<JustClick.BLL.JobPosting> JobPostID; JobPostID = JustClick.DAL.DataRepository.JobPostingProvider.GetByJobPostingID(PostID); }   But on int PostID = JobID[0].JobPostingID; i'm getting the error NullReferenceException Object reference not set to an i

Declaring variables with values

In SQL Server 2008, I know I can declare variables as follows: DECLARE @var INT = 1; Instead of: DECLARE @var INT; SET @var = 1; Is the first example ANSI compliant?  just wondering in case we ever have to port some code.  Also, since this is really the first time I've had to concern myself with ANSI SQL standards, what's the best way to stay informed of them?  Kind of a noob question, I know, but your input is appreciated. Clint

session variables and master pages

Hi all: I have a master page and 2 content pages. In the master page I use a session variable. As it, I suppose this session variable is read by the two content pages. But it isn't working. This session variable is read by the first content page and not the second. Why? Thanks in advance if you can help me      

Populate a Data Flow Task's variables with values from a .dtsConfig file?

I have an SSIS Project to import exchange rates from an XML file into SQL. The project works when I have certain values hard-coded into variables, such as the URL of the XML File, proxy username and passwords etc. I decided to put in a .dtsConfig file, and have it update the values of the variables in the data flow task. So, one of my SSIS Packages in this solution is called ECBDailyRates.dtsx. It contains one control flow, which is a data flow task. The data flow task is a script task which does some XPATH on an XML file, and then provides outputs to an OLE DB Destination, which in turn puts the data into a table in SQL. That much worked before I put in the dtsConfig file. There are a few variables declared inside the data flow task, such as; PricesXMLUriDaily, String ProxyAddress, String ProxyAddressPort, Int32 etc. etc. These are now being updated from the dtsConfig, which is below. It was my understanding that SSIS would run through the config, and update any of the variables as required, and then run my data tasks. However when SSIS runs my script task, none of the variables have been populated, and so it falls over... as it were :) <?xml version="1.0"?> <DTSConfiguration> <DTSConfigurationHeading> <DTSConfigurationFileInfo GeneratedBy="...." GeneratedFromPackageName="dim_Institution" GeneratedFromPackageID="

SSIS: How to set the values of the variables, other ways of setting the values of the variables?

Hi Gurus, Is this the only way in setting the values of the variables. Please see steps below: 1. Build the SSIS Project. From the package's property pages, Deployment Utility, set the CreateDeploymentUtility to TRUE (It will create a Deployment Folder and inside the folder 3 files will be created a) SSISDeploymentManifest b) dtsConfig c)dtsx ) 2. Double click the SSISDeploymentManisfest file. A Package installation will be set up. 3. Follow the steps until you reach the Configuration Packages: Edit package configurations window. 4. From the Configuration part, set the values from the Values(column). 5. To Finish. Is this the only way of setting the values of the variable?

Session Variables and Session Timeouts

I added the following code to global.asax to load up several session variable when a session starts. I'm assuming that when a page goes to use the variable that I should be 1) checking at the page level that the value is valid not 0 when its not expected to be 0, not a zero-length string when its expected to have a length 2) have code at the page level that sets the values if the values have not been set as when the Session timeout, ideally putting the code in a class derived from Page and then deriving all of my pages from the new class so that the code does not have to be repeated in every page Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a new session is started 'Move code here that sets the User Session Variables, currently done in the code behind of DefaultDirectory and the Dashboard Masters Dim ExceptionMessage As New StringBuilder ExceptionMessage.Append("Site accessed using " + Request.Browser.Browser + " " + Request.Browser.MajorVersion.toString + "." + Request.Browser.MinorVersion.tostring) Dim NewException As New NotSupportedException(ExceptionMessage.ToString) Elmah.ErrorSignal.FromCurrentContext().Raise(NewException) Dim CurrentUser As New MercurySiteUser.SiteUser() Session("UserE

Sharing the session variables between two .net applications using SQL Server Mode?

Hi, I have two different IIS applications within the same domain(let us say www.mydomain.com) , both of these applications use the same database instance(same connectionstring), now what I want is that both of applications can see each sessions variables , can SQL Server session state mode helps in this case? Did someone try that before? Is there any other way to share the session variables? Please help.  

How to pass session variables from .net to coldfusion


We are in the process of refactoring from cf to .net, so, I am working on the Login page and converting it from cf to .net. So, when I am autheticated and enter into our website, I need to redirect it to a cfm page (just temporary, since we will be refactoring that also eventually).

So, I am autheticated (using CustomMembership Provider model for sql server) and then when I redirect to the cfm, the app.cfm should validate the .net session variables. Here is where i am stuck:

I have the .net session variables in the aspx side:something like

Session["UserId"].ToString() = Value from a login txt box (also authenticated against data in the database)

Session["UserName"].ToString() = Value from the db corresponding to the User Name entered in the text box.



So, now I have all the session variables in the .net side. Now, how do I retreive these .net session in the cf side? Any small peice of code to retrive the asp.net session variable in the application.cfm side would be great.

ASP.NET session variables, do you need to save each time?


Anytime you change the object variable that is already assigned to a session variable, do you need to "re-save" the variable back into the session variable or does it do it automatically?

For example:

// abc is an object of some random type

Session["abc"] = abc;  // initial declaration of session variable.

abc.a=1;  // updated abc.a field after a button_click event

Session["abc"] = abc;   // resave the new field value of 'a' back into the session variable 'abc'.

Or does the session variable already keep track of all changes made to the object and saves automatically?


Session and session variables not stable in development server....


Hi I have a strange problem in a website that runs in a server to which I am connected through VPN...

I use some session variables to get the job done(shopping cart, etc) but it is not stable..manytimes I get no items in session object and other times(refreshing the page) I get missing data...I downloaded the entire site code to my local pc and debugged it and run it succesfully without any session data missing...When I run it in the server, I get bad session again: no products in shopping cart or products with missing quantities...

The same website runs smoothly in our production server too....The problem is with our development server...

Any help would be greatly appreciated..

Thanks in advance,


Session variables are accessible to multiple users?


I have an asp.net website in which users can submit reports. Another tester and I tested this page at the same time and when I went to review the information I submitted, it displayed information that I didn't submit. It displayed the info submitted from the other user.

I use session variables for these values. I don't understand how this happened?

What can I do so each user can individually submit their information without overlapping some one else's information? The plan is for multiple users to be able to use this page to submit their weekly layer reports.

The first example of code is how I add the session variables from the textboxes.

If Session("BarnNo") = Nothing Then
                                'add session variables
                                    Session.Add("FName", FNameTextbox.Text)
                                    Session.Add("LName", LNameTextbox.Text)
                                    Session.Add("WkEnd", Calendar1.SelectedDate.ToShortDateString())
                                    Session.Add("DisplayDate", Calendar1.SelectedDate.ToLongDateString)

                                    Session.Add("BarnNo", BarnNumberTextbox.Text)
                                    Session.Add("FlockNo", FlockNoTextbox.Tex
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend