473,487 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Session Reference

Don
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"
Nov 18 '05 #1
3 1209
Try using HttpContext.Current.Session and HttpContext.Current.Request

"Don" <an*******@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
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")

Nov 18 '05 #2
Don
There are no properties of httpcontext
Nov 18 '05 #3
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" <an*******@discussions.microsoft.com> wrote in message
news:AD**********************************@microsof t.com...
There are no properties of httpcontext

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2553
by: TS | last post by:
I was under the impression that when you get a reference to an object, then update that reference, the object gets updated. Apparently this isn't the case using session? code (note at this point...
2
3155
by: Jason | last post by:
I have a Session object set on Session_Start... I figured out that the object is never created... Cannot understand why.. Also I noticed that the debugger will not stop at breakpoints that are...
9
2363
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
8
1099
by: One Handed Man [ OHM# ] | last post by:
Scenario. PDA connecting to a web service method using a reference on XP professional ( IIS ). XP limited to 10 sessions. How can the session be released once the method has finished. IE to log...
2
1156
by: tshad | last post by:
I was looking at different ways of doing the same thing and at the moment was looking at the use of "is" and "=", as I have at times found that I will do something like if something = 0 and...
13
1732
by: | last post by:
Simple question, I think... I'm storing an object in the Session object. In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction) If I change any...
1
2566
by: Santosh | last post by:
Dear All i am writting a code sending mail with attachement. i am writting code for sending mail in one page and code for attaching a file in the next page. aftet attaching a file i am taking...
6
7159
by: tshad | last post by:
Is there a reason to use session.remove over session.contents.remove? Don't they both remove the key and data from the contents collection? I assume that session(x) = nothing does essentially...
2
3304
by: Krishna | last post by:
hi, I am anand.I used session state object in some pages in my application ex Session("UserId"). some times applications displayed the following error Object reference not set to an instance...
3
2807
by: Benton | last post by:
Hi there, Currently I have a rather simple class with a few members: string userName; string password; string centers; bool canModify; I have correspondant GET properties for them in the...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5442
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.