473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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="TestApplication.UserInfoClass"
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 1985
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.com> wrote in message
news:ed**************@TK2MSFTNGP10.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="TestApplication.UserInfoClass"
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.nospam> wrote in message
news:uj**************@TK2MSFTNGP10.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.com> wrote in message
news:ed**************@TK2MSFTNGP10.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="TestApplication.UserInfoClass" 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.com> wrote in message
news:%2****************@TK2MSFTNGP12.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.nospam> wrote in message
news:uj**************@TK2MSFTNGP10.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.com> wrote in message
news:ed**************@TK2MSFTNGP10.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="TestApplication.UserInfoClass" 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
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...
14
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...
5
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...
4
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...
4
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...
2
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...
0
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...
2
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.