views:

30

answers:

2

I have 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?

+5  A: 

Try it like this:

HttpContext.Current.Session("person_name")
XIII
Make sure you test `HttpContext.Current` for `null` first. I'm not sure how the class is used, but if it's ever utilized outside the request/response scope, the context could be null.
Toby
+2  A: 

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

Chris Shouts