Re: Access Session State from a Class

Discussion in 'ASP .Net' started by Marcelo Dabanovich Lavio, Aug 13, 2004.

  1. Hi Carlo,

    If your BLL is always loaded into the process space (same AppDomain as) the
    ASP.NET front-end (which is the case if your BLL is a simple class library
    project being referenced by your ASP.NET projetc), then you can access the
    ASP.NET session state using the class System.Web.HttpContext. On your BLL
    dll project, add a reference to System.Web, and on your code, access the
    session data this way

    System.Web.HttpContext.Current.Session["abc"]

    Marcelo


    "Carlo Marchesoni" <> wrote in
    message news:...
    > I have an ASP.NET/c# solution with
    > - FE (an ASP.NET Project)
    > - BLL(a C# Project with Classes)
    >
    > In the FE I set some Session State variable (Session["abc"] = "whatever"),
    > but I found no way to retrieve this session state value in the classes of

    the
    > BLL Project (obviousely I can pass the values in the signatures, that's

    what
    > I'm doing right now).
    > I'm sure there is a way to do it directly (string s = Session["abc"]) but
    > I'm unable to find out how.
    > Thanks for any suggestion
     
    Marcelo Dabanovich Lavio, Aug 13, 2004
    #1
    1. Advertising

  2. Thanks a lot for your help Marcelo, it works perfectly

    "Marcelo Dabanovich Lavio" wrote:

    > Hi Carlo,
    >
    > If your BLL is always loaded into the process space (same AppDomain as) the
    > ASP.NET front-end (which is the case if your BLL is a simple class library
    > project being referenced by your ASP.NET projetc), then you can access the
    > ASP.NET session state using the class System.Web.HttpContext. On your BLL
    > dll project, add a reference to System.Web, and on your code, access the
    > session data this way
    >
    > System.Web.HttpContext.Current.Session["abc"]
    >
    > Marcelo
    >
    >
    > "Carlo Marchesoni" <> wrote in
    > message news:...
    > > I have an ASP.NET/c# solution with
    > > - FE (an ASP.NET Project)
    > > - BLL(a C# Project with Classes)
    > >
    > > In the FE I set some Session State variable (Session["abc"] = "whatever"),
    > > but I found no way to retrieve this session state value in the classes of

    > the
    > > BLL Project (obviousely I can pass the values in the signatures, that's

    > what
    > > I'm doing right now).
    > > I'm sure there is a way to do it directly (string s = Session["abc"]) but
    > > I'm unable to find out how.
    > > Thanks for any suggestion

    >
    >
    >
     
    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=, Aug 16, 2004
    #2
    1. Advertising

  3. Marcelo Dabanovich Lavio

    Padmanabh

    Joined:
    Jan 14, 2009
    Messages:
    1
    Hi Marcelo,

    just wanted to ask you...

    what if my BLL class liabrary is loaded into different Process Space..
    I have a callback delegate which is having a function reference of my WebApp.
    When that delegate gets called..I get the System.Web.HttpException for Page.Session as both the projects are running in differnt space

    thanks,
    Padmanabh Ganorkar
     
    Padmanabh, Jan 14, 2009
    #3
  4. Marcelo Dabanovich Lavio

    metalpower

    Joined:
    Sep 26, 2007
    Messages:
    3
    thanks you for this useful post save my day :)
     
    metalpower, Mar 31, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shamanthakamani
    Replies:
    1
    Views:
    3,500
    Natty Gur
    Nov 20, 2003
  2. Not Liking Dot Net Today
    Replies:
    0
    Views:
    618
    Not Liking Dot Net Today
    Apr 21, 2004
  3. Maciek
    Replies:
    0
    Views:
    8,257
    Maciek
    Sep 15, 2005
  4. jnickfl1
    Replies:
    0
    Views:
    595
    jnickfl1
    Sep 18, 2006
  5. Harry Haller
    Replies:
    0
    Views:
    1,663
    Harry Haller
    Nov 7, 2006
Loading...

Share This Page