473,398 Members | 2,188 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,398 software developers and data experts.

Accessing session information from another project in a solution

Hi,

I have a session variable in an asp.net web project that I would like to
access from a C# project in the same solution.

When I try and use the Session variable e.g. acc =
Session["accountcode"]; in the C# project I get the following error:

C:\Inetpub\wwwroot\Optima Online\DataLibrary\DataClass.cs(272): The name
'Session' does not exist in the class or namespace 'DataLibrary.DataClass'
I have tried adding a "using System.Web.SessionState;" line to the file but
it doesn't make any difference.

Is this possible?
Mike
Jul 21 '05 #1
2 3724
"Mike Grace" wrote:
I have a session variable in an asp.net web project that I would like to
access from a C# project in the same solution.

When I try and use the Session variable e.g. acc =
Session["accountcode"]; in the C# project I get the following error:

C:\Inetpub\wwwroot\Optima Online\DataLibrary\DataClass.cs(272): The name
'Session' does not exist in the class or namespace 'DataLibrary.DataClass'


Session (and Request, Response, etc) are properties of both Page and
UserControl. If you need to access them outside these classes, you should
use HttpContext.Current to get a reference:

using System.Web;

acc = HttpContext.Current.Session["accountcode"];

With kind regards,

Steven

- - -

Jul 21 '05 #2
Thank you.

Regards

Mike

"Steven Spits" <no****@company.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
"Mike Grace" wrote:
I have a session variable in an asp.net web project that I would like to
access from a C# project in the same solution.

When I try and use the Session variable e.g. acc =
Session["accountcode"]; in the C# project I get the following error:

C:\Inetpub\wwwroot\Optima Online\DataLibrary\DataClass.cs(272): The name
'Session' does not exist in the class or namespace
'DataLibrary.DataClass'


Session (and Request, Response, etc) are properties of both Page and
UserControl. If you need to access them outside these classes, you should
use HttpContext.Current to get a reference:

using System.Web;

acc = HttpContext.Current.Session["accountcode"];

With kind regards,

Steven

- - -

Jul 21 '05 #3

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

Similar topics

3
by: AARON PECORARO | last post by:
I need to split apart my web application into multiple projects to allow it to be distributed in parts, but all of the projects need to work together (ie. they need to share session information)....
5
by: Michelle A. | last post by:
I have a four page form. Pages 1-3 stores there information in a session variables. Page four is reached (a final review page) and then the information will be written to the SQL server. When...
4
by: Bill Dodd | last post by:
Is there really no way to have different asp.net applications share session variables? The problem I'm running into is that I have numerous asp.net (and asp) applications that were written as...
4
by: Cowboy \(Gregory A. Beamer\) | last post by:
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...
4
by: Charles | last post by:
I am still having problems with sessions crossing over from other sessions. What I mean by this is that Mary may get just some or all of Renaeā€™s information. I think that what is going on with...
2
by: Mike Grace | last post by:
Hi, I have a session variable in an asp.net web project that I would like to access from a C# project in the same solution. When I try and use the Session variable e.g. acc = Session; in...
5
by: Ryan | last post by:
I have a SQLDataSource I want to tie to the currently logged in user. Is there any way to use User.Identity().Name as a Parameter in the datasource? The only way I've got this to work is by...
4
by: Nick Gilbert | last post by:
Hi, Is it possible to access the Session of an arbitary user from an aspx page? On an e-commerce site, I am notified of payment success via a callback from the payment server to an ASPX page...
8
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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...
0
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...

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.