Session from CustomAction

Discussions about DocuVieware integration in GdPicture.NET.
Post Reply
swegele
Posts: 2
Joined: Fri May 13, 2016 11:25 pm

Session from CustomAction

Post by swegele » Sat May 14, 2016 9:32 am

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?

swegele
Posts: 2
Joined: Fri May 13, 2016 11:25 pm

Re: Session from CustomAction

Post by swegele » Sat May 14, 2016 11:43 am

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

svr
Posts: 3
Joined: Wed Sep 14, 2016 11:44 am

Re: Session from CustomAction

Post by svr » Thu Feb 23, 2017 8:29 am

Unfortunately it doesn't work for me. After adding this to the global.asax the custom action stops firering. Are there any other solutions?

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Session from CustomAction

Post by Cedric » Thu Feb 23, 2017 11:49 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest