DocumentUltimate - Session has expired
Problem reported by Alexander Peters - Yesterday at 11:33 PM
Resolved
Hello!
I’m currently testing DocumentUltimate, and I’ve noticed a problem during testing that I don’t know how to fix. Whenever I open several documents in quick succession, each in its own window, I get the message shown in the screenshot. I found an article via Google that said I should set CookielessSessionMode.Always. But I don’t have the `GleamTechWebConfiguration` for that—I only have the `DocumentUltimateWebConfiguration`, which doesn’t have that setting. 
My application is a Windows application that’s supposed to display documents in DocumentUltimate within separate browser windows. 

Thanks for your help

Best regards,
Alex


GleamTechWebConfiguration.Current.CookielessSessionMode = CookielessSessionMode.Always;


Cem Alacayir Replied
Employee Post
Firstly, GleamTechWebConfiguration is in GleamTech.Common.dll so you need to reference that DLL along with GleamTech.DocumentUltimate.dll. When you are using PackageReference (NuGet), this is not required as GleamTech.Common package is automatically referenced as a transitive dependency. But when manually referencing GleamTech.DocumentUltimate.dll you need to also reference GleamTech.Common.dll to be able access types inside that DLL.

My application is a Windows application that’s supposed to display documents in DocumentUltimate within separate browser windows. 
So is your application a Winforms or Wpf application (an Windows exe) ? DocumentViewer only runs in a web application (ASP.NET application). If you are opening a URL that hosts DocumentViewer in browser control in a Windows application, make sure session handling is enabled in that browser control. Also you can set CookielessSessionMode in the host ASP.NET Application (server application) and not your client application.
Alexander Peters Replied
Hello,
We're using a Windows Forms application, and the DocumentViewer runs within a web application. In our application, we use a WebView2 with cookies enabled, and it works fine when I open a single document, then open another document, and so on.  However, if I select three documents, for example, and open them all at once, three windows open in my application—each containing a WebView2—and they all make a GET request to the web application. As a result, I receive a message stating that the session has expired. 

Thanks for pointing out the GleamTech.Common.dll. I'll give it a try.



Cem Alacayir Replied
Employee Post Marked As Resolution
This may be helpful:

To share a session (cookies, localStorage, and cache) between multiple WebView2 controls, they must share the same browser process by pointing to the exact same User Data Folder (UDF). By default, WebView2 controls initialized under the same UDF pool resources and state seamlessly. [1, 2]
The implementation details vary based on how you intend to share the session:

1. Same Application, Multiple WebView2 Instances
If you want multiple WebView2 controls within the same application to share login sessions, pass the same CoreWebView2Environment to all instances.


// 1. Create a shared environment pointing to a specific UDF
var userDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "YourAppName");
var environment = await CoreWebView2Environment.CreateAsync(null, userDataFolder);

// 2. Assign the same environment to all WebView2 controls before initialization
await webView1.EnsureCoreWebView2Async(environment);
await webView2.EnsureCoreWebView2Async(environment);

Reply to Thread

Enter the verification text