How to Persist WebView2 Session Across Workspace Switches and Smart Client Restarts in MIP Plugin

We are developing a MIP Smart Client plugin that embeds our web application using Microsoft WebView2.

The authentication happens completely inside the embedded web application. After the user logs in, one of the authentication cookies is created as a session cookie, meaning it does not have an Expires or Max-Age value.

We are facing two related issues:

  1. When the XProtect Smart Client is closed and reopened, the session cookie is lost and the user is required to log in again.

  2. Even without closing the Smart Client, if the user switches from our Spectra workspace plugin to another workspace, such as the Alarm Manager, and then returns to the Spectra workspace, the WebView session is lost and the user is required to log in again.

We would like the embedded WebView to preserve its authenticated session while switching between Smart Client workspaces, and ideally also across Smart Client restarts.

We are already using a persistent WebView2 user data folder.

Questions:

  1. Is there a recommended way in a MIP Smart Client plugin to keep the WebView/WebView2 instance or session alive when switching between workspaces?

  2. Does XProtect destroy and recreate the plugin workspace/view content when the user switches to another workspace?

  3. Is there any lifecycle method or recommended MIP SDK pattern for retaining WebView state between workspace changes?

  4. Is there a supported way to persist or restore the WebView2 session across Smart Client restarts?

  5. Are there any known limitations when using a persistent WebView2 profile inside the Smart Client?

  6. Is there a recommended approach used by other MIP plugins for maintaining authenticated web sessions?

We cannot modify the authentication flow of the embedded web application, so we are specifically looking for a solution that can be handled from the MIP plugin/WebView2 side.

From a MIP SDK perspective, the answer to question 2 is yes. This means the plugin itself must persist and restore any required session and state information.

  • For workspace switches, a background plugin can be used to help maintain state while the Smart Client remains running.
  • When the Smart Client is closed, a background plugin will not help. Any session or state that needs to survive a Smart Client restart must be persisted by the plugin and restored when it starts again.

There is no MIP SDK sample that demonstrates preserving WebView2 (or similar component) session and state across workspace changes and Smart Client restarts.

Also, WebView2 is an external Microsoft component. We do not have specific experience with WebView2 in Milestone Support and therefore cannot provide guidance on WebView2-specific session handling or persistence mechanisms.

Is there any other component that is recommended or provided by the MIP SDK that should be used to embed the web view in the plugin?

The built-in HTML Page view item in the XProtect Smart Client uses an embedded Internet Explorer browser engine. This component has limited support for modern web technologies and may not behave as expected with newer web applications. A related Knowledge Base article discussing alternative browser plugins can be found here: Alternative Browser Plugin

It is also possible to configure the browser emulation mode up to Internet Explorer 11. See the Knowledge Base article Web Pages Fail for details.

That said, I would not recommend switching to the built-in HTML Page browser for this scenario. Since you are already using a WebView2-based solution, you likely have a much more capable browser component available. Unfortunately, I do not have enough experience with embedding browser components to recommend a specific approach or component. Perhaps another developer following this can share some experience.