Session Reference

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"
 
R

Russ Farris

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.
 
R

Russ Farris

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top