Reading a Asp.Net Session Variable in MVC Controller

~J~

~J~

Soldato
Joined
20 Oct 2003
Posts
7,558
Location
London
Two part question:

Does anyone have any example code that shows me how I can read a Session variable, that a web user control in an Asp.Net application has set, in an MVC Controller?

I've tried using HttpContext.Session([sessionvariablename]) but that's just not returning a value at all.

Second part is, that while I've been trawling the web to shed some light on this problem, I'm seeing a lot of people saying I shouldn't be using Session variables at all, yet no one is saying why? I understand it's bad practice to store a shed-load of data, but just a simple "CountryId=44" as a Session variable surely isn't that bad, is it?
 
Last edited:
Back
Top Bottom