Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Problem with Session State

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Morgan - 15 Dec 2007 22:51 GMT
I am using asp.net 2.0

I have not used session state for some time possibly just in ASP.net
1.1 and ASP

I have always found it a simple technique but now in ASP.NET 2.0 I am
getting a perplexing problem and I would be most grateful for some
help.

I have an ASPX 2.0 page which has the following code:

****************************

 Session("userID") = 22
 
 response.redirect ("walkEntry.aspx")
 
 ********************************
 
 The walkEntry,aspx page has the following code:
 
 
 Sub page_load......
 
 dim intUserID as integer
 
  intUserID = Session("userID")
   Response.Write(intUserID)
   
   end sub
**************************************
   When the code is run the walkEntry.aspx page shows the intUserID
value as 0
   
   If I then go to the browser window and re-enter the page and press
Enter on the keyboard then walkEntry.aspx shows up properly and  the
intUserID value shows up correctly as  22
   
   
   Where am I going wrong?
   
   Best wishes, John Morgan
Hal Rosser - 16 Dec 2007 05:22 GMT
>   intUserID = Session("userID")
>    Response.Write(intUserID)
[quoted text clipped - 9 lines]
>
>    Where am I going wrong?

Try casting. If you have Option Strict On.
The Session variable is stored as an object - not as an Integer.
Something like this may work:
intUserID = CInt( Session("UserID") )

HTH
Hal
John Morgan - 16 Dec 2007 12:03 GMT
Thanks Hal for your suggestion but I still cannot get it to work.

I have looked at a couple of reference books, altered my code and am
still unsuccessful

Option strict is off

I have tried the following on the 'loginuser.aspx' page

   txtUserID.Text = CStr(123)

       Session.Item("userID") = (txtUserID.Text)

       Response.Write(Session.Item("userID"))
         
    That works in that the response write shows
Session.Item("userID") correctly as 123
   
    I then alter the code to
   
      Session.Item("userID") = (txtUserID.Text)    
       Response.Write(Session.Item("userID"))
       Response.Redirect("enterWalk.aspx")
       
       
       and then try to pick up Session.Item("userID") from the
"enterWalk.aspx" with the following code
       
           Sub page_load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
           
    Dim intUserID As String = CType(Session.Item("userID"), String)
           Response.Write("intUserID" & intUserID)
           
   End Sub    
           
           The intUserID is not picked up.
           
           Can you or anyone supply code which is guaranteed to work?
I think I am missing something fundamental,
           
           Best wishes, John Morgan

>>   intUserID = Session("userID")
>>    Response.Write(intUserID)
[quoted text clipped - 17 lines]
>HTH
>Hal

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.