Accessing session, application variables in the mo

HevePybeate

New Member
I want to access session or application variables in the module functions or in a class. I do not want to pass session variable in module function. Is there any other way to access these variables.<BR><BR>Thank you very much for your help.<BR>Pravin<BR>include the System.Web.SessionState Namespace in you class and use the Session Object just like in Classic ASP.Can you give me some more hint on it, like I have a session variable 'session("name")' on 'test.aspx.vb' page and I want to access this session variable on the Module page.<BR>I did import on module page like this:<BR>Imports System.Web.SessionState<BR>but it does not work, do I need to create some kind of object to access this 'session("name")'.<BR>PLEASE HELP ME. THANKS A LOT<BR>what do you mean by "module page"? Is it a class file?Module page is not same as a class file, extensions for these files are same 'fileName.vb'.<BR>we can create Module that can contain functions or sub routines and to access these functions from '*.aspx.vb' files we do not need to create an object like a class file.<BR><BR>Module testModule<BR>&nbsp;&nbsp;&nbsp;&nbsp;Function returnName()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'******************* <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' I WANT TO ACCESS SESSION VARIABLE HERE<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '*******************<BR>&nbsp;&nbsp;&nbsp;&nbsp;End Function<BR>End ModuleSo, if you are using modules, much like the *.bas equivalent in VB6, you simply need to reference the session correctly (through the HttpContext):<BR><BR>Module modTest<BR> Public Function testSession() As String<BR> testSession = HttpContext.Current.Session("strTest")<BR> End Function<BR>End ModuleIs there a way to access the Request object collection from within a class? I tried importing system.web.httprequest namespace but I get an error that Request.Form is not valid in the context.<BR><BR>Thanks,<BR><BR>DaveTry this<BR>HttpContext.Current.Request.Form("txtName")Thanks a lot, it works great.<BR>Pravin
 
Back
Top