Welcome Guest Search | Active Topics | Sign In | Register

EO WebBrowser CookieManager, options for sharing cookies with .NET HttpClient? Options
mh_dev
Posted: Thursday, June 10, 2021 5:58:34 PM
Rank: Newbie
Groups: Member

Joined: 6/10/2021
Posts: 3
Let's say you're building a WPF application, for example, and have included EO.WebBrowser control in the app, the web view will load some urls and the WebEngine manages all the cookies the various web views in the app will have as part of their requests.

NOW.. If you also have native .NET code in the app that also makes server requests, say with .NET HttpClient, what are some methods to enable synchronization between the CookieContainer used by the HttpClient for native app requests and the requests within the EO.WebBrowser web views?

I understand the WebEngine has and exposes a Cookie Manager and has equivalent classes Get/Set Cookie operations, but the synchronization part is what hangs me up.
https://www.essentialobjects.com/doc/eo.webengine.cookiemanagermembers.aspx

Because cookies can come and go from either webview requests or native HttpClient requests you have possibility of conflicts or race conditions and I wasn't sure what patterns folks use to keep both distinct "clients" in sync with one another and manage conflicts and avoid over complicated schemes to do so.
eo_support
Posted: Friday, June 11, 2021 1:52:08 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

No. EO.WebBrowser has its own "Cookie Jar" and it does not share its cookie with anyone else. Not even to Google Chrome browser (which uses the same Chromium browser engine). It does not share cookies with .NET's own HttpClient class either. The Cookie Jar is also isolated between multiple instance of EO.WebEngine.Engine object.

In your case, you can try to port your code that uses HttpClient to use WebView.LoadRequest. That way it will automatically pick up whatever cookies that's already there.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.