0

I tried to use Session state inside an event receiver's itemupdated event but it threw this error: Object not set to an instance of an object.

I have attached this event receiver to a form library. Perhaps this info will help.

this is all what I used:

public override void ItemUpdated(SPItemEventProperties properties)
{
 HttpContext.Current.Session["OldValue"] = "Some value";
}

Edit: One more thing. I have enabled session state in sharepoint. these are the steps that I have followed:

1) Enable-SPSessionStateService –DefaultProvision
2) <pages enableSessionState="true" in web.config
3) <add name="Session" type="System.Web.SessionState.SessionStateModule" /> inside modules element in web.config

Have I forgotten something?

Any idea why it is throwing this error?

Imir Hoxha
  • 1,674
  • 6
  • 31
  • 56
  • Almost all cases of `NullReferenceException` are the same. Please see "[What is a NullReferenceException in .NET?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net)" for some hints. – John Saunders Apr 01 '13 at 19:15
  • session is a static variable and it does not need instatiation. you know it better, please explain. HttpContext.Current.Session["OldValue"] = "Some value"; – Imir Hoxha Apr 01 '13 at 20:10
  • If in case you did not read the subject, this is about sharepoint and sharepoint requires a few more configurations to work. – Imir Hoxha Apr 01 '13 at 20:27
  • 1) It's not `Session` that's the problem, it's `Session["OldValue"]`. 2) Yes, I know it's SharePoint. Same universe, however. Same rules. – John Saunders Apr 01 '13 at 20:32

0 Answers0