473,748 Members | 10,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session level Object

I've got an ASP.NET application and I need some information on every page
like the user's name as well as a collection listing which sections of the
application the user has access to. I could store the user name in a regular
session variable but the collection varies in size based on the user and
could grow in the future as the application grows. I don't want to keep
going back to the database for this info every time because it's needed on
every page.What I would like to do is have a session level "USER" object
that stores this information in memory but I have not been able to figure
out how to do this. I have been looking on the web and I found this syntax:

<object id="UserInfo" runat="server" class="TestAppl ication.UserInf oClass"
scope="Session" />

This looks like exactly what I am looking for except I don't know how to add
this to my global.asax file. It does not belong in the codebehind
global.asax.vb file and there is no html view of the global.asax file. I'm
stumped.

Any help would be greatly appreciated.

Paul Ross
Hebco, Inc.
Nov 18 '05 #1
5 2011
Paul,

Storing a "User" object in session state does not save anything over just
using a normal session variable. They are both held in memory on the
server. The object approach stores the data in a nice package, but it isn't
more (or less efficient) than just storing session variables.

Other things to be careful about when using sessions is that if using a web
farm (load balanced servers), the session ID will not transfer between
servers.

The most common approach is to use a database. This is the most scalable
and robust solution. Yes, you will need to make trips to the db server, but
you are not holding anything in web server memory.
"Pross" <ta******@aol.c om> wrote in message
news:ed******** ******@TK2MSFTN GP10.phx.gbl...
I've got an ASP.NET application and I need some information on every page
like the user's name as well as a collection listing which sections of the
application the user has access to. I could store the user name in a
regular session variable but the collection varies in size based on the
user and could grow in the future as the application grows. I don't want
to keep going back to the database for this info every time because it's
needed on every page.What I would like to do is have a session level
"USER" object that stores this information in memory but I have not been
able to figure out how to do this. I have been looking on the web and I
found this syntax:

<object id="UserInfo" runat="server" class="TestAppl ication.UserInf oClass"
scope="Session" />

This looks like exactly what I am looking for except I don't know how to
add this to my global.asax file. It does not belong in the codebehind
global.asax.vb file and there is no html view of the global.asax file. I'm
stumped.

Any help would be greatly appreciated.

Paul Ross
Hebco, Inc.

Nov 18 '05 #2
I'm not looking for efficiency over session variables. Using a simple object
would make it easier and to navigate some of the hierarchical data. For
instance my "Job" object contains a collection of "Task" objects that
describe each separate task that makes up a job. Some Jobs have 1 task and
some others have 20. The session variable (at least as I have used them) are
great for single pieces of data but don't seem to be able to hold
hierarchical data in a way that would be easy to deal with.

I have been able to create global object in the application by a couple of
different methods but only one object gets created and all the clients are
modifying that one object. What I would like to do is to have a copy of this
object for each client logged in. I know this has some potential side
effects not the least of which is memory but this is an internal web app and
I don't anticipate a lot of simultaneous users. I plan to do a lot of
testing of whatever solution I come up with but I would like to be able to
evaluate this idea as a solution. I was hoping to get some help in making it
work.

Paul Ross
Hebco, Inc.

"Scott M." <s-***@nospam.nosp am> wrote in message
news:uj******** ******@TK2MSFTN GP10.phx.gbl...
Paul,

Storing a "User" object in session state does not save anything over just
using a normal session variable. They are both held in memory on the
server. The object approach stores the data in a nice package, but it
isn't more (or less efficient) than just storing session variables.

Other things to be careful about when using sessions is that if using a
web farm (load balanced servers), the session ID will not transfer between
servers.

The most common approach is to use a database. This is the most scalable
and robust solution. Yes, you will need to make trips to the db server,
but you are not holding anything in web server memory.
"Pross" <ta******@aol.c om> wrote in message
news:ed******** ******@TK2MSFTN GP10.phx.gbl...
I've got an ASP.NET application and I need some information on every page
like the user's name as well as a collection listing which sections of
the application the user has access to. I could store the user name in a
regular session variable but the collection varies in size based on the
user and could grow in the future as the application grows. I don't want
to keep going back to the database for this info every time because it's
needed on every page.What I would like to do is have a session level
"USER" object that stores this information in memory but I have not been
able to figure out how to do this. I have been looking on the web and I
found this syntax:

<object id="UserInfo" runat="server"
class="TestAppl ication.UserInf oClass" scope="Session" />

This looks like exactly what I am looking for except I don't know how to
add this to my global.asax file. It does not belong in the codebehind
global.asax.vb file and there is no html view of the global.asax file.
I'm stumped.

Any help would be greatly appreciated.

Paul Ross
Hebco, Inc.


Nov 18 '05 #3
Paul,

Are you aware that objects can be persisted in the ASP.NET state bag (view
state)? This allows you to make an instance of your object, populate it and
then place it in the ViewState state bag for retrieval on another page
request.
"Pross" <ta******@aol.c om> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I'm not looking for efficiency over session variables. Using a simple
object would make it easier and to navigate some of the hierarchical data.
For instance my "Job" object contains a collection of "Task" objects that
describe each separate task that makes up a job. Some Jobs have 1 task and
some others have 20. The session variable (at least as I have used them)
are great for single pieces of data but don't seem to be able to hold
hierarchical data in a way that would be easy to deal with.

I have been able to create global object in the application by a couple of
different methods but only one object gets created and all the clients are
modifying that one object. What I would like to do is to have a copy of
this object for each client logged in. I know this has some potential side
effects not the least of which is memory but this is an internal web app
and I don't anticipate a lot of simultaneous users. I plan to do a lot of
testing of whatever solution I come up with but I would like to be able to
evaluate this idea as a solution. I was hoping to get some help in making
it work.

Paul Ross
Hebco, Inc.

"Scott M." <s-***@nospam.nosp am> wrote in message
news:uj******** ******@TK2MSFTN GP10.phx.gbl...
Paul,

Storing a "User" object in session state does not save anything over just
using a normal session variable. They are both held in memory on the
server. The object approach stores the data in a nice package, but it
isn't more (or less efficient) than just storing session variables.

Other things to be careful about when using sessions is that if using a
web farm (load balanced servers), the session ID will not transfer
between servers.

The most common approach is to use a database. This is the most scalable
and robust solution. Yes, you will need to make trips to the db server,
but you are not holding anything in web server memory.
"Pross" <ta******@aol.c om> wrote in message
news:ed******** ******@TK2MSFTN GP10.phx.gbl...
I've got an ASP.NET application and I need some information on every
page like the user's name as well as a collection listing which sections
of the application the user has access to. I could store the user name
in a regular session variable but the collection varies in size based on
the user and could grow in the future as the application grows. I don't
want to keep going back to the database for this info every time because
it's needed on every page.What I would like to do is have a session
level "USER" object that stores this information in memory but I have
not been able to figure out how to do this. I have been looking on the
web and I found this syntax:

<object id="UserInfo" runat="server"
class="TestAppl ication.UserInf oClass" scope="Session" />

This looks like exactly what I am looking for except I don't know how to
add this to my global.asax file. It does not belong in the codebehind
global.asax.vb file and there is no html view of the global.asax file.
I'm stumped.

Any help would be greatly appreciated.

Paul Ross
Hebco, Inc.



Nov 18 '05 #4
If this process creates a separate instace for each user that that's exactly
what I want. Do you know a good site to read up on this?

Thanks,

Paul Ross
Hebco, Inc.
Nov 18 '05 #5
Scott,

I was reading another post and I discovered something that I'm sure you knew
all along but I did not know. I came from old ASP where session variables
were only strings and I thought that was still the case. I read a post where
someone was just assigning their objuct directly to a session variable. I
did not know that you could do that. I'm sorry for wasting your time. I
tried this and it works exactly like I'd hoped. If only everysolution in
life were this easy. Well back to the grind.

Paul Ross
Hebco, Inc.
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2028
by: Scott Wickham | last post by:
I'm having a problem saving session information on one form and retrieving it on a subsequent form...for only one out of a number of users. Actually, I'm not absolutely certain it's a session problem but I'm hoping the experts can help me figure that out. Our application uses a session variable to "pass" info from one form to the next. It has always worked fine for our users until a few weeks ago when one of our users started having a...
14
3236
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you go to is a login form, which will set several session variables with the name used to log in, appropriate security level and some other misc variables, and then will go to a main menu for each particular security level using Server.Transfer. ...
5
6328
by: PJ | last post by:
I posted a few days ago concerning requests being blocked from a main window after a popup window had initiated a file download. Apparently this has to do with the fact that asp.net or iis serialize all requests from the same session. Further requests from the same session are being queued until the download is complete. So, is there any way to override this? Is there anyway to tell asp.net to not serialize same session requests? Is...
4
1657
by: VB Programmer | last post by:
If I have a variable I want to share in my application what is the difference between just declaring a variable (Dim strMyVar as String) and using a session variable (Session("strMyVar"))? When should I use a session variable and when should I just declare it like normal? Thanks in advance!
4
1679
by: Dean | last post by:
I finally got class session variables to work by putting the following in global.asax in the session_start: dim myDBComp as DBComp = new DBComp........ session("myDBComp") = myDBComp In each aspx codebehind module I can define my object right after the class definition as so: dim myDBComp as DBComp The problem I had was where to put the instantiation:
2
1095
by: George Birbilis | last post by:
Hi all, I'd like to have an error handler proc installed that can grab unhandled errors during a Session before the Session object goes down. I mainly want to log some info kept at the session state upon such an exception, before I propagate it to the system again Now I'm catching the errors at global.asax.vb which is too late, since it's at the Application level and the Session has already died. So I can only log user's IP address, the...
0
1635
by: Nabani Silva | last post by:
Hi, hope someone could help I need to share session state (and contents) through differente web applications. I'm trying to get it done by using StateServer session state, below I paste code for web.config. Both applications are on the same server (I don't want to include all applications into one common virtual directory or application)
2
2134
by: Markus Prediger | last post by:
Hi NG, I have an asp.net project that uses an vb6 com object for some database-manipulation (I cannot rewrite it in .net, sorry, its not my decision). I want it to be instanciated seperately for each session, so that three users can connect to three different databases. But I get crazy because: -With interop all users share one instance - pure chaos (the instance is
4
5326
by: Bjorn Sagbakken | last post by:
In a web-application with login creds (user, pwd), these are checked against a user table on a SQL server. On a positive validation I have saved the userID, name, custno and role-settings in a userobject (custom build class) and added this to the session using as session variable like session For all other pages I have added a small test in the page_load event, basically testing if the session != null, but also checking if the...
0
8984
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.