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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.