cod*_*ife 1 c# chromium-embedded cefsharp
这个问题让我困惑了好几天了.我完全无法设置cookie CefSharp.
这是我期望工作的代码块(更多是因为它可以是天真的,不包括显式线程上下文切换):
Application.Current.Dispatcher.Invoke(new Action(() =>
{
var settings = new CefSettings();
settings.CachePath = "cookies";
Cef.Initialize(settings);
Cef.DeleteCookies("", "");
Cef.VisitAllCookies(new CookieVisitor()); // <-- doesn't get called, so assuming we've cleared all the persistent cookies here...
Cef.SetCookiePath("/", false);
Cef.VisitAllCookies(new CookieVisitor()); // <-- ok guess im paranoid...
var isSet = Cef.SetCookie("/", "username",
"testuser", "tovalrsv01", "/",
false, false, false, new DateTime(2020, 1, 1));
Cef.VisitAllCookies(new CookieVisitor()); // <-- isSet is false, and i don't see the cookie that i created in the visited list...
}));
Run Code Online (Sandbox Code Playgroud)
我只是想知道我是否错过了一些重要的概念.我是新手CefSharp,尽管已经仔细研究了这些例子和论坛,但我很可能在这里错过了一些东西.非常感谢任何见解或指针!
Argggh!经过更多的试验和错误,我想出来了.本网站上的一篇文章帮助我进行了调查:
https://groups.google.com/forum/#!topic/cefsharp/SflbtatvTqQ
尝试传入域的空字符串而不是"/",或者将Url传递为"/ mywebsite",将域传递为"192.16.1.6"
这让我想知道我的cookie params是否因为某种原因被拒绝了.我最终试图用这些参数设置cookie:
var isSet = Cef.SetCookie("http://tovalrsv01:8142/", "username", "testuser", "", "/", false, false, false, new DateTime(2020, 1, 1));
更严格地指定URL是诀窍.我猜DNS别名有时不够好.无论如何,我将离开这篇文章以防其他人CefSharp遇到类似的情况.
| 归档时间: |
|
| 查看次数: |
4978 次 |
| 最近记录: |