954,198 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Session in app_code

i have a class in app_code folder which implements the Ihttphandler Interface.so when the execution enter in the Processrequest method i have to use the session variables created on login page.but there is no such Session Object present there.

on login page i hav created session like this

session("userid")=dr("user")

i hav context which is object of Httpcontext class which is a input parameter in the Processrequest method.

with this context object i have wrote

dim user as string =context.Session.Item("userid")

but this will genearte an error

An exception of type 'System.NullReferenceException' occurred in App_Code.7qviugdw.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.


how can access session inside this class?

kapil.goyal
Light Poster
47 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 
i have a class in app_code folder which implements the Ihttphandler Interface.so when the execution enter in the Processrequest method i have to use the session variables created on login page.but there is no such Session Object present there. on login page i hav created session like this session("userid")=dr("user") i hav context which is object of Httpcontext class which is a input parameter in the Processrequest method. with this context object i have wrote dim user as string =context.Session.Item("userid") but this will genearte an error An exception of type 'System.NullReferenceException' occurred in App_Code.7qviugdw.dll but was not handled in user code Additional information: Object reference not set to an instance of an object. how can access session inside this class?

You can use HttpContext.Current.Session() Instead.

Hausen
Newbie Poster
1 post since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You