Re: Session Variables Disappearing
From: Alvin Bruney [MVP] (vapor)
Date: 02/16/04
- Next message: Milan Negovan: "Re: Session Variables Disappearing"
- Previous message: Milan Negovan: "Re: Session Variables Disappearing"
- In reply to: Paul Yanzick: "Re: Session Variables Disappearing"
- Next in thread: Paul Yanzick: "Re: Session Variables Disappearing"
- Reply: Paul Yanzick: "Re: Session Variables Disappearing"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 15 Feb 2004 22:16:02 -0600
you have custom controls on that page? custom controls cannot directly
access session, you need to first get a reference to the session object from
httpcontext.current.
If that still doesn't work, you will need to put code to display the session
variable in the page load and troubleshoot from there
if(Session["UserName"]!= null)
Response.Write("<script>alert('" + Session["UserName"].ToString() +
"')</script>");
should display something
-- Regards, Alvin Bruney [ASP.NET MVP] Got tidbits? Get it here... http://tinyurl.com/3he3b "Paul Yanzick" <yanzickp@hotmail.com> wrote in message news:-sudnUOIdbqWgq3dRVn2sg@giganews.com... > Hello! > > The session state information in the web.config is as follows: > > <sessionState > > mode="InProc" > > stateConnectionString="tcpip=127.0.0.1:42424" > > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" > > cookieless="false" > > timeout="20" > > /> > > There is no <pages> element in the Web.config. I want to have the session > variables be available to all of the pages in the project. > > Most of the variables that are in the session state are strings, so I use > (string) to cast them. For example, in the status bar user control, I use: > lblUserName.Text="Logged in using: " + Session["UserName"].ToString(); > > lblSecurity.Text="Security Level: " + > Authenticate.GetSecurityLevelText((int)Session["SecurityLevel"]); > > The first line accesses the session directly, and uses ToString() to get the > info. The second line I am casting it to an integer to throw into the > function. The funny thing with these and the status bar is once it logs on > and takes you to the menu, all of the info is currect, however if I move > past that, the first line produces 'Logged in using:' and that is it, while > the second line produces absolutely nothing. > > Thanks for your help! > > Paul > > > > "Milan Negovan" <santa@northpole.net> wrote in message > news:TXSXb.10685$cE3.17376713@news4.srv.hcvlny.cv.net... > > Hi Paul, > > > > > > > I don't receive any errors, there just isn't anything that appears in > these > > > fields. Each page has sessions enabled. If you have any suggestions, > > > PLEASE let me know! > > > > You mentioned each page had session enabled. Is there a chance the > > session is disabled in web.config? What does your <sessionState> element > > look like? > > > > Also, do you happen to have a <pages> element in web.config that > > disables the session state for certain files? > > > > Also, how do you cast values you read from the Session object? > > > > -- > > Milan Negovan > > www.AspNetResources.com > > Essential recources for ASP.NET developers > >
- Next message: Milan Negovan: "Re: Session Variables Disappearing"
- Previous message: Milan Negovan: "Re: Session Variables Disappearing"
- In reply to: Paul Yanzick: "Re: Session Variables Disappearing"
- Next in thread: Paul Yanzick: "Re: Session Variables Disappearing"
- Reply: Paul Yanzick: "Re: Session Variables Disappearing"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|