Session in app_code

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2007
Posts: 47
Reputation: kapil.goyal is an unknown quantity at this point 
Solved Threads: 0
kapil.goyal kapil.goyal is offline Offline
Light Poster

Session in app_code

 
0
  #1
Mar 1st, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1
Reputation: Hausen is an unknown quantity at this point 
Solved Threads: 0
Hausen Hausen is offline Offline
Newbie Poster

Re: Session in app_code

 
0
  #2
Mar 6th, 2008
Originally Posted by kapil.goyal View Post
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.
Last edited by Hausen; Mar 6th, 2008 at 2:38 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC