在webBrowser1.Navigate(url)中设置Cookie的注意点

 [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
 public static extern bool InternetSetCookie(string lpszUrlName, string lbszCookieName, string lpszCookieData);
InternetSetCookie("http://"+url, null, cookie);
//屏蔽webBrowser中的脚本错误
webBrowser1.ScriptErrorsSuppressed = true;
 webBrowser1.Navigate(url);

注意:不能直接用InternetSetCookie(url,null,cookie)这里的url一定要带:http://,调试中要注意查看区分。我就是这里没有注意花了很长时间才解决!!

原文地址:https://www.cnblogs.com/firstcsharp/p/5700173.html