473,326 Members | 2,076 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,326 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 3706
"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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.