开发者

Unable to access Session State from class?

开发者 https://www.devze.com 2023-01-06 00:34 出处:网络
I hav开发者_JS百科e a Dynamic Data application to which I have added a class for extending EDM. Everything works great, but now I am trying to set an entity property value equal to a value in session

I hav开发者_JS百科e a Dynamic Data application to which I have added a class for extending EDM. Everything works great, but now I am trying to set an entity property value equal to a value in session state - and its not recognizing the Session command. I'm trying to do something like this:

audit.action_by = CStr(Session("person_name"))

I think this is because I do not have the class Inheriting Page, but if I do add Inherits Page it breaks other stuff. How can I have the class include the ability to utilize sessions directly without inheriting Page?


Try it like this:

HttpContext.Current.Session("person_name")


The Session property of the Page and UserControl classes is just a shortcut for HttpContext.Current.Session.


if HttpContext.Current.Session is not working,than use like this System.Web.HttpContext.Current.Session

0

精彩评论

暂无评论...
验证码 换一张
取 消