Page 1 of 1
Session from CustomAction
Posted: Sat May 14, 2016 9:32 am
by swegele
I need access to Session variables when handling CustomActions events on the server. When I debug the Session property of HTTPContext.Current is null.
I have important business objects stored in session. They work together with imaging functionality controlling auditing, permissions, etc.
Can you help?
Re: Session from CustomAction
Posted: Sat May 14, 2016 11:43 am
by swegele
I think I figured out a solution. Add this to your Global.asax.cs and scope it to the level of docuviewerapi method that you want. Here I am attaching Session (read-only) to all of the api calls. ReadOnly ensures that multiple concurrent api calls won't block each other while waiting for a previous call to unlock writeable session.
Code: Select all
protected void Application_BeginRequest(object sender, EventArgs e)
{
//if docuviewerapi api method then lets attach session (readonly to minimize blocking)
if (HttpContext.Current.Request.Path.Contains("dvapi2/docuviewareapi"))
{
HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.ReadOnly);
}
}
Viola...session is available in the CustomActions and other methods triggered on server from DocuVieware!
Sean
Re: Session from CustomAction
Posted: Thu Feb 23, 2017 8:29 am
by svr
Unfortunately it doesn't work for me. After adding this to the global.asax the custom action stops firering. Are there any other solutions?
Re: Session from CustomAction
Posted: Thu Feb 23, 2017 11:49 am
by Cedric
I just tested with the latest release available (2.0.61) and I am unable to replicate the issue, it works as expected.
The custom action is firing properly and I am able to access the Session data I set in the Page_Load without issue.