Session Reference

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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"
 
Try using HttpContext.Current.Session and HttpContext.Current.Request

Don said:
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.
 
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.
 
Back
Top