472,965 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,965 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 3613
"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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.