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
精彩评论