I find a big unknown and it is that it does not allow me to create a Session[""]
in a class file only in a controller file.
Does anyone know what this is about or how could I create one there?
I find a big unknown and it is that it does not allow me to create a Session[""]
in a class file only in a controller file.
Does anyone know what this is about or how could I create one there?
You should define the using a System.Web
and use
HttpContext.Current.Session[]
the webpage inherits from Page, that's why you can directly access the Session object, but a class does not do it.
If that class executes within a web environment it could access the objects by means of HttpContext.Current
What is the difference between these two HttpContext.Current.Session and Session - asp.net 4.0