Session Reference

Discussion in 'ASP .Net' started by =?Utf-8?B?RG9u?=, May 19, 2004.

  1. I have a module where I have common routines. When I want to use it I place the following on top of the sompage.aspx.v

    imports Mycode.CWPS.CWPSCod

    I then call a routine that I want to use. Here's the question: How do I get reference to the session of the page that called me. What I currently have is

    dim session as sessionstat

    a = session.sessioni

    I get an error saying System.NullReferenceException: Object reference not set to an instance of an object

    How do I get the reference to the session and also httpreques

    dim request as httpreques

    b = request.servervariables("REMOTE_ADDR"
     
    =?Utf-8?B?RG9u?=, May 19, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?RG9u?=

    Russ Farris Guest

    Try using HttpContext.Current.Session and HttpContext.Current.Request

    "Don" <> wrote in message
    news:...
    > I have a module where I have common routines. When I want to use it I

    place the following on top of the sompage.aspx.vb
    >
    > imports Mycode.CWPS.CWPSCode
    >
    > I then call a routine that I want to use. Here's the question: How do I

    get reference to the session of the page that called me. What I currently
    have is
    >
    > dim session as sessionstate
    >
    > a = session.sessionid
    >
    > I get an error saying System.NullReferenceException: Object reference not

    set to an instance of an object.
    >
    > How do I get the reference to the session and also httprequest
    >
    > dim request as httprequest
    >
    > b = request.servervariables("REMOTE_ADDR")
    >
    >
     
    Russ Farris, May 19, 2004
    #2
    1. Advertising

  3. There are no properties of httpcontext
     
    =?Utf-8?B?RG9u?=, May 19, 2004
    #3
  4. =?Utf-8?B?RG9u?=

    Russ Farris Guest

    Make sure your Class has Imports System.Web

    I had the same problem as you. I created a new class with several shared
    functions so that I didn't have to create an instance each time. After, I
    imported System.Web it all worked.


    "Don" <> wrote in message
    news:...
    > There are no properties of httpcontext
     
    Russ Farris, May 19, 2004
    #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. Darren
    Replies:
    0
    Views:
    519
    Darren
    Oct 11, 2004
  2. Jeff Smythe
    Replies:
    3
    Views:
    1,325
    Jeff Smythe
    Jan 2, 2004
  3. Dude
    Replies:
    0
    Views:
    379
  4. =?Utf-8?B?Um9iSEs=?=
    Replies:
    4
    Views:
    5,415
    =?Utf-8?B?Um9iSEs=?=
    Apr 11, 2007
  5. Jazzis
    Replies:
    2
    Views:
    279
    Jazzis
    Sep 23, 2003
Loading...

Share This Page