views:

169

answers:

1

Hi, can someone give me an example or link to one of using a session in asp.net mvc?

+5  A: 

The same as in WebForms:

Use the HttpContext.Current.Session object.

HttpContext.Current.Session["UserName"] = "Jon";

string userName = HttpContext.Current.Session["UserName"];
User
You posted 10 seconds earlier! ^^
Arnis L.
Trimack
There is one small section on sessions in Professional ASP.NET MVC 1.0 book (written by the authors of the framework) and they make use of standard ASP.NET Sessions as shown above.
Ray Vernagus
Thats enough for me then. Thanks.
Trimack