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

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

"Global" session data

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net

I am storing some information in a Session variable. I have a Structure that contains a number of separate items including login data and shopping basket data. At the end of the Page_LoadComplete event I store the structure as follows:?

Current.Session("SessionPool") = Spl

And I retrieve it at the start of the Page_Load event as follows:

Spl = Current.Session("SessionPool")

Throughout my logic I refer to items within the structure such as spl.loginrow (a datarow) and spl.basket (a datatable).

I am testing the (remote) web site from two independent PCs. I change the quantity of items for one line in the shopping basket on one PC then, on the other PC, I refresh the basket and, hey presto, it reflects changes I have made on the first PC.

This suggests to me that the session variable is being shared across all sessions somehow - i.e. it is being managed at an application level. Does this make any sense? Any suggestions about what kind of dumb mistake I could have made here?

View Complete Post

More Related Resource Links

Add a global parameter to your ado.net entity data model which can be used to validate a session var


is there a way to add a global parameter to your ado.net entity data model which can be used to validate a session variable ? in that way you could have a general rule to get for instance only the records belonging to a specific user's profile logged in, is that possible?

In case that it were possible doing that way you will be making the rule valid for all entities in your model at once. right? 

Using Session to pass data between forms


In my app, I am displaying an Rss Feed, I have a button that takes the user to another form where they can select a them.  Upon selecting the theme, they are taken back to the original form. 

If the user has selected which theme they want to view then they click on the button to change theme, I need to pass the information about what rss feed they were viewing through session so that once they select the theme they want they are redirected back to the main page and the rss feed they were viewing should still be displayed.

Since I've already bound the data to the xmlDataSource and DataList I am trying the following:

Session.Add("CurrentRssFeed", XmlDataSource1.DataFile);

Session.Add("CurrentDataList", DataList1);

I'm not sure I am passing the data over correctly and I'm not sure how to specify it in the page_preinit.

Any ideas???

send data in class object from one page to another using session


hello everybody

now i hav stored all data like user name, data fatched from database of that user

and i stored that data and user name such as:

string strUserName="user name"

dataset ds =new dataset();// data of that user

now i wan yo send d whole data from my login page to user profile page

can anybody help me for that...................

and plz tell me that how much is this way is benifitial to send data from one page to another page

plz........kindly waiting for positive rply

Changing aspx page causes session data to be lost...


Strange but true. Any ideas what might be causing this?


Global Variables and data types

Hi, I have a small issue with the datatype problems. This is what my scenario is. I have a global variable "Qtr" declared as "Int32" datatype. Next, i have a ActiveXscript with VBScript Language. With the below piece of code. All it does, it will calculate and assign the calculated value to the global variable "Qtr". But due to some datatype conversion problem it is not displaying the Calculated value. It is showing null. But the value in the local variable is getting displayed. Can anyone figure out what the problem is all about. I have the option of taking the String datatype for the global variable but in the next step in the workflow , we have an stored procedure call i.e. an execute sql task where we will be call a stored procedure EXEC sp ? where the parameter datatype is an INT in the database. That is why i am finding problem.  I have used the work around i.e. using SSIS advanced expressions and avoided the parameter mapping and all. Function Main() 'msgbox("test") Dim Qtr Dim currentYear 'Constants qYears = 3 Qtr= (currentYear - qYears) * 10 + 4 msgbox(Qtr) msgbox("Assigning the value to the variable") DTSGlobalVariables("Qstart").Value =  Cint(Qtr) msgbox("Display Value in the variable") MsgBox(DTSGlobalVariables("Qtr").Value)      End Function Can a

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. 

Storing large data in Session State

Hi, We have a scenario where we need to store large tables of data on Session in asp.net page. on a highlevel we have to store following data  1> A table (table 1) with 1000 rows and 8 to 10 columns. 2> A table(table 2) with 500 rows and 8 to 10 columns (actually user can add the data from table 1 to table 2, so as user keeps on adding from table 1 we remove the data and put it in table 2) 3> Another table(table 3) with 1000-1200 rows each having 3 columns. We are having a webfarm, so we need to store it in either SateServer of Oracle DB, please advise which one is better. What would be the performance implications of storing such huge data on the server. One more thing is at any point of time max of 70 -80 people will be accessing our website, so will this cause any performance degradation? Thanks in anticipation Harsha

Retriving data from CheckBoxList and passing it to a Session



I wondering how can I retrive data from a CheckBoxList in c#. and once I get the data I would like to store the data in a session so I can use the data from a session on a another page

Thank you in advance

Data in session



I'm trying to work out what to do with some data I have which is used throughout a users session.

I need to hold up to 200 integers for a customer - not all customers will have 200, some may have none at all.

When I look at what this will consume in session, 1Gb of memory would be enough to support 2m users with full allocation. Even with an extremely busy site, say 1000 simultaneous users, memory would not be stretched.

With this in mind the obvious conclusion is to put the data in session, particularly as the tables data is retrieved from may contain 1m records.

The question I have is - is there anything else i need to consider - any hidden gremlins that I need to watch out for, or is it as simple as that?



Clearing Session Data from Modeless Popup window.


I am using Post method to generate crystal reports. The user requirement is to show the report in a modeless pop up screen. 

The session data needs to be cleared as it may at times contain a very large dataset.  

One implementation I have placed in at present is - placing a button "Close Button". When user clicks close button, I am able to clean up the session content as well as close the window.

The issue I am facing is to get the handle of the modeless window when it is closed using the x button. Also, since the pop up window is modeless, the user might have moved to another screen, henceforth the parent of the popup window is already changed or out of context.

How do we clear the sesssion content when the issue condition arises?

Please provide suggestions.

Passing data to a Controller from global.asax


Hello all! I'm in a situation where I need to pass some information (state) to a base controller from which all of my controllers derive. In my global.asax, I'm calling a web service to get some state about the user. This state applies to every page in my web app, so the base controller needs to know about it. The state consists of about 4 fields. Is there a standard way to do this? 

I'm using ASP.NET MVC 2.

Thanks in advance for your time!


Session end and global.asax



I'm wondering if ther's a simple way of achieving the following.

When a new session starts, I create some cookies and session objects from global.asax session start.

If a user logs out, I want to abandon the session - I presume using session.abandon, and i also want to clear the cookies.  They are set to expire after the session ends (no expiry date).  This may be an automatic thing, but I've not tested as yet.

When a user logs back in again I want to recreate those objects - in other words, kick off global.asax again.  Is that what happens or do I need to recreate manually?



How can I manage session data outside the ASP.Net session object?


I want to be able to persist data across a session but do this outside of the built-in session state object.  Why is a long story that I will not go into here.  I just need to know where I can put data other than in the session object that will persist across the specific session (in memory - I already have a database solotion).


Session and global asax


i use session state for logged in  users
if session lost(finished) for user and i use this session to insert as a forien key in a table
this will generate runtime error as this id become equal to zero
how can i develop a method to log out the user automatically when session timeout reached
inseted to check at every button on the velue of session.
i have ideia to check on session on global file in Application_BeginRequest event

but give me error
what do you think of this method???

Retrieve data from SQL server based on login username (session data)



I'm trying to make a dropdown list with data available based on the users login name. Heres what I have as my SQL Query in the SQLDataSource:

SELECT Client_Name, Client_ID FROM Client WHERE (Client_Name LIKE '%@Client_Name%')

So say if the login username is "User1" but the database client name is "User1 Steel" I want the dropdownlist to pull "User1 Steel" as the display and Client_ID as the value from the dropdown list. 

I dont know how to use the session data!

Using session data for SQL query



How would I go about using my session data (ie username) for an SQL query to populate a dropbox? Here is what I have so far:

SELECT Client_Name, Client_ID FROM Client WHERE (Client_Name LIKE '%@Client_Name%')

Am I on the right track?

SSIS - Global Data SOurce - Password issues


I have a simple solution with (right now) 4 packages, 3 configuration files and one "global" datasource.  Here is the View Code on the data source:

<DataSource xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0" xsi:type="RelationalDataSource" dwd:design-time-name="02d8345e-665e-4bd8-9323-1e846af220e5" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
  <ID>PPDM37 Staging</ID>
  <Name>PPDM37 Staging</Name>
  <ConnectionString>Provider=SQLNCLI.1;Data Source=engsql03.dev.ihs.com;Persist Security Info=True;Password=;User ID=;Initial Catalog=PPDM37_Staging</ConnectionString>

As you can see, the <ConnectionStringSecurity> node is set with PasswordRemoved.  When editing the data source and checking the Keep Password option on it still saves wit

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