v8 - HttpContext.Current.Session IS NULL in EditorModelEventManager.SendingContentModel event
Hi friends,
I am back-porting some code I wrote for a v10 site to use in a v8 site, but having issues...
Basically, I am trying to get the currently-loading node Id (when opening a content node in the back-office for editing), and store that id so I can retrieve it for use in a property editor's rendering.
Using the 'SendingContentModel' event, in my v10 site I was able to set a Session variable, but in v8, when I try to set a Session variable, the Session is always NULL:
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public class StoreUmbracoSessionInfoEventComponent : IComponent
{
public void Initialize()
{
EditorModelEventManager.SendingContentModel += StoreUmbracoSessionInfo;
}
public void Terminate()
{
// Unsubscribe during shutdown
EditorModelEventManager.SendingContentModel -= StoreUmbracoSessionInfo;
}
private void StoreUmbracoSessionInfo(
System.Web.Http.Filters.HttpActionExecutedContext sender,
EditorModelEventArgs<Umbraco.Web.Models.ContentEditing.ContentItemDisplay> e)
{
//if this is NOT an Element, Store the current node info in Session var
if (e.Model.IsElement == false)
{
HttpContext context = HttpContext.Current; //THIS IS NOT NULL
context.Session["UmbracoNode"]= e.Model.Id; //NULL REF ERROR HERE - .Session is NULL
}
}
}
I have added the following to web.config to enable Session State - perhaps something is missing here?
v8 - HttpContext.Current.Session IS NULL in EditorModelEventManager.SendingContentModel event
Hi friends,
I am back-porting some code I wrote for a v10 site to use in a v8 site, but having issues...
Basically, I am trying to get the currently-loading node Id (when opening a content node in the back-office for editing), and store that id so I can retrieve it for use in a property editor's rendering.
Using the 'SendingContentModel' event, in my v10 site I was able to set a Session variable, but in v8, when I try to set a Session variable, the Session is always NULL:
I have added the following to web.config to enable Session State - perhaps something is missing here?
I also looked at storing it in a cookie, but couldn't get that to work either.
Seems something was missing from the web.config - a 'Session' module:
After adding that, it now works as expected. 🙂
is working on a reply...