Im using a session variable to pass the user ID from the Index to the Create in the HomeController. ATM the user can use a drop down to select their name from the list of users and click 'View' to list the holidays they have previously booked. From there the user can click 'create' which will bring the user to a page which enables them to create a new holiday. From here they have to select their name again from the drop down list.
I want to store the users ID from the previous drop down so it will update automatically if they try to create another holiday (to replace the second drop down)
Im using a session variable to do this, iv put
Session["userameID"] = currentID;
in my view. Iv break pointed it just after and if I hold my mouse over 'currentID' it displays the correct ID of the user.
So iv tried to pass this down to the create method using
string xx = (string)Session["usernameID"];
However string 'xx' is returning NULL,., (tested with breakpoint)
I then placed the entire session in the view
Session["userameID"] = HolidayDate;
string xx = (string)Session["usernameID"];
and string 'xx' is still returning null.
Is it not meant to return the userID???
Thanks for any replys
[session] returns null
Page 1 of 13 Replies - 1336 Views - Last Post: 18 December 2012 - 06:20 AM
Replies To: [session] returns null
#3
Re: [session] returns null
Posted 18 December 2012 - 04:19 AM
ok thanks for that, anyone have any ideas?
#4
Re: [session] returns null
Posted 18 December 2012 - 06:20 AM
Is there anyway you can post the actual code where you're setting the session value and the code where you're retrieving it? In the above code you have a Session["userameID"] and a Session["usernameID"]. I'm kind of assuming one was just a typo when posting here, but if not then that could be causing a problem.
Also, something to be mindful about is that Session has a default timeout of 20 minutes. If for some reason your user moves to the second page and then has to leave their PC for some reason there's a chance that the Session value will timeout before they return which could potentially cause some problems if not handled correctly.
Also, something to be mindful about is that Session has a default timeout of 20 minutes. If for some reason your user moves to the second page and then has to leave their PC for some reason there's a chance that the Session value will timeout before they return which could potentially cause some problems if not handled correctly.
This post has been edited by Nakor: 18 December 2012 - 06:21 AM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|