Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am new in mvc3.

I have Create Session in accountcontroller with this code
static string usernameSessionVar = "username";
C#
System.Web.HttpContext.Current.Session[usernameSessionVar] =id.user_id; System.Web.HttpContext.Current.Session.Timeout = 2880;

and that can be access in other controller with this code

static string usernameSessionVar = "username";
 int id=Convert.ToInt16(System.Web.HttpContext.Current.Session[usernameSessionVar]); 


it is work fine in local server. but when site upload then it is not work.
please me how to create session in mvc3.

Thank You.
Posted
Updated 3-May-12 0:24am
v2

1 solution

Session is used for the TempData store. TempData is a highly limited form of session state which will last only until the next request from a certain user. (Edit In MVC 2+, it lasts until it is next read.) The purpose of TempData is to store data, then do a redirect, and have the stored data be available to the action to which you just redirected.

Using Session for the TempData store means that any distributed caching system which already handles Session will work for TempData. Avoiding using Session directly when TempData will do has a couple of advantages. One is that you don't have to clean up the Session yourself; TempData will "expire" on its own.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900