Sharing Session variables across applications

  • Thread starter Thread starter Cowboy \(Gregory A. Beamer\)
  • Start date Start date
C

Cowboy \(Gregory A. Beamer\)

Background:
-------------
The idea started as a single sign on type of application. Having tested it
before, I knew we could institute single sign on using the same
Authentication Cookie name (in this case "AuthenticationCookie" -- yeah,
original, I know) and the same machine keys for the applications.

<authentication mode="Forms">
<forms name="AuthenticationCookie" path="/"
loginUrl="login.aspx" protection="All" timeout="10" />
</authentication>

<machineKey
validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E34
00267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"
validation="3DES"
/>

When a user logs into one application, they can move back and forth between
apps. And, the user uses the same session ID in both applications (confirmed
by output of session ID), so it appears as if he is just moving from section
to section in a single app, rather than moving back and forth between
multiple apps. Everything is fine and beautiful ... until today.

The Problem
-------------
I have a colleague who sets up everything in session variables. As his app
is complete already, moving away from Session variables will be too time
consuming to be a realistic solution. The problem is you cannot share
application variables across app boundaries like so:

APP 1: Session["PassedID"] = UserID;
APP 2: UserID = Convert.ToDecimal(Session["PassedID"]);

The one clue I have is the error messages states something about the wrong
namespace, which suggests to me that the namespace has to be used to pull
the variable. This would mean that there is another syntax to pull Session
vars, otther than:

UserID = Convert.ToDecimal(Session["PassedID"]);

In a nutshell: I need basic syntax to pull from same session, different
application (namespace).

My other ideas:

1. Store to some form of temporary persistant storage (XML File, SQL table,
et al) and use Session ID to pass information back and forth.

2. Try the Caching Application Block and see if the Framework allows cross
application use of information.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************************************************
Think outside the box!
***************************************************************
 
'sup Cowboy?

How about using SQL Server to store the Sessions, and then you should be
able to execute queries to get the Session values from the other app?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
That is the direction I pushed: Create an object with 'void
SetSessionItem(string SessionID, string Key, string Value)', 'string
GetSessionItem(string SessionID, string Key)' and 'DataSet
GetAllSessionItems(string SessionID)'. You can then store in any persistant
storage (in this case Oracle, which is the client's standard).

The other developer still wants to set
'Session["AlltheStuffICanStickInSession"] = someGarbage;' in one app and
then use 'Object someGarbage = Session["AlltheStuffICanStickInSession"] ' on
the second app. So, if anyone figures out a way to solve this, I would love
a heads up.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
Kevin Spencer said:
'sup Cowboy?

How about using SQL Server to store the Sessions, and then you should be
able to execute queries to get the Session values from the other app?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Cowboy (Gregory A. Beamer) said:
Background:
-------------
The idea started as a single sign on type of application. Having tested it
before, I knew we could institute single sign on using the same
Authentication Cookie name (in this case "AuthenticationCookie" -- yeah,
original, I know) and the same machine keys for the applications.

<authentication mode="Forms">
<forms name="AuthenticationCookie" path="/"
loginUrl="login.aspx" protection="All" timeout="10" />
</authentication>

<machineKey
validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E34
00267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"
validation="3DES"
/>

When a user logs into one application, they can move back and forth between
apps. And, the user uses the same session ID in both applications (confirmed
by output of session ID), so it appears as if he is just moving from section
to section in a single app, rather than moving back and forth between
multiple apps. Everything is fine and beautiful ... until today.

The Problem
-------------
I have a colleague who sets up everything in session variables. As his app
is complete already, moving away from Session variables will be too time
consuming to be a realistic solution. The problem is you cannot share
application variables across app boundaries like so:

APP 1: Session["PassedID"] = UserID;
APP 2: UserID = Convert.ToDecimal(Session["PassedID"]);

The one clue I have is the error messages states something about the wrong
namespace, which suggests to me that the namespace has to be used to pull
the variable. This would mean that there is another syntax to pull Session
vars, otther than:

UserID = Convert.ToDecimal(Session["PassedID"]);

In a nutshell: I need basic syntax to pull from same session, different
application (namespace).

My other ideas:

1. Store to some form of temporary persistant storage (XML File, SQL table,
et al) and use Session ID to pass information back and forth.

2. Try the Caching Application Block and see if the Framework allows cross
application use of information.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************************************************
Think outside the box!
***************************************************************
 
Get rid of the other developer?

;-)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Cowboy (Gregory A. Beamer) said:
That is the direction I pushed: Create an object with 'void
SetSessionItem(string SessionID, string Key, string Value)', 'string
GetSessionItem(string SessionID, string Key)' and 'DataSet
GetAllSessionItems(string SessionID)'. You can then store in any persistant
storage (in this case Oracle, which is the client's standard).

The other developer still wants to set
'Session["AlltheStuffICanStickInSession"] = someGarbage;' in one app and
then use 'Object someGarbage = Session["AlltheStuffICanStickInSession"] ' on
the second app. So, if anyone figures out a way to solve this, I would love
a heads up.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
Kevin Spencer said:
'sup Cowboy?

How about using SQL Server to store the Sessions, and then you should be
able to execute queries to get the Session values from the other app?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

message news:[email protected]...
tested
validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E34
00267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"
validation="3DES"
/>

When a user logs into one application, they can move back and forth between
apps. And, the user uses the same session ID in both applications (confirmed
by output of session ID), so it appears as if he is just moving from section
to section in a single app, rather than moving back and forth between
multiple apps. Everything is fine and beautiful ... until today.

The Problem
-------------
I have a colleague who sets up everything in session variables. As his app
is complete already, moving away from Session variables will be too time
consuming to be a realistic solution. The problem is you cannot share
application variables across app boundaries like so:

APP 1: Session["PassedID"] = UserID;
APP 2: UserID = Convert.ToDecimal(Session["PassedID"]);

The one clue I have is the error messages states something about the wrong
namespace, which suggests to me that the namespace has to be used to pull
the variable. This would mean that there is another syntax to pull Session
vars, otther than:

UserID = Convert.ToDecimal(Session["PassedID"]);

In a nutshell: I need basic syntax to pull from same session, different
application (namespace).

My other ideas:

1. Store to some form of temporary persistant storage (XML File, SQL table,
et al) and use Session ID to pass information back and forth.

2. Try the Caching Application Block and see if the Framework allows cross
application use of information.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************************************************
Think outside the box!
***************************************************************
 
I have a wild idea. how about this:

iterate thru the running applications on the webserver. this will bring back
a list of the running apps. get the attached application object assigned to
each app. with the application object, get the httpcontext object associated
with this, and on down thru to the session object. This is a similar
approach to finding a control in a page, except that it would be starting
with a running application.

There is one fly in the ointment. Classes and the methods are private, so
you could try changing the class specifier to public instead of private.
ya, i know. it's very ugly. but that would conceivably get you passed the
access issue without having to add new code to a completed project. i have
no idea if this will work or if it even makes sense, it's just a thought
requiring a brazen hack. but then again, you are an MVP.

--
Regards,
Alvin Bruney
Got DotNet? Get it here
http://home.networkip.net/dotnet/tidbits/default.htm
Cowboy (Gregory A. Beamer) said:
That is the direction I pushed: Create an object with 'void
SetSessionItem(string SessionID, string Key, string Value)', 'string
GetSessionItem(string SessionID, string Key)' and 'DataSet
GetAllSessionItems(string SessionID)'. You can then store in any persistant
storage (in this case Oracle, which is the client's standard).

The other developer still wants to set
'Session["AlltheStuffICanStickInSession"] = someGarbage;' in one app and
then use 'Object someGarbage = Session["AlltheStuffICanStickInSession"] ' on
the second app. So, if anyone figures out a way to solve this, I would love
a heads up.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
Kevin Spencer said:
'sup Cowboy?

How about using SQL Server to store the Sessions, and then you should be
able to execute queries to get the Session values from the other app?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

message news:[email protected]...
tested
validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E34
00267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"
validation="3DES"
/>

When a user logs into one application, they can move back and forth between
apps. And, the user uses the same session ID in both applications (confirmed
by output of session ID), so it appears as if he is just moving from section
to section in a single app, rather than moving back and forth between
multiple apps. Everything is fine and beautiful ... until today.

The Problem
-------------
I have a colleague who sets up everything in session variables. As his app
is complete already, moving away from Session variables will be too time
consuming to be a realistic solution. The problem is you cannot share
application variables across app boundaries like so:

APP 1: Session["PassedID"] = UserID;
APP 2: UserID = Convert.ToDecimal(Session["PassedID"]);

The one clue I have is the error messages states something about the wrong
namespace, which suggests to me that the namespace has to be used to pull
the variable. This would mean that there is another syntax to pull Session
vars, otther than:

UserID = Convert.ToDecimal(Session["PassedID"]);

In a nutshell: I need basic syntax to pull from same session, different
application (namespace).

My other ideas:

1. Store to some form of temporary persistant storage (XML File, SQL table,
et al) and use Session ID to pass information back and forth.

2. Try the Caching Application Block and see if the Framework allows cross
application use of information.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************************************************
Think outside the box!
***************************************************************
 
Back
Top