var urlValue = string.Format(url, key, id, dic);
MessageBox.Show(urlValue);
browser = new ChromiumWebBrowser(urlValue);
browser.RequestHandler = new CustomRequestHandler();
browser.Parent = panel1;
browser.Dock = DockStyle.Fill;
browser.DownloadHandler = new DownloadHandler();
public class CustomResourceRequestHandler : ResourceRequestHandler
{
protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
var headers = request.Headers;
headers["User-Agent"] = "My User Agent";
request.Headers = headers;
return CefReturnValue.Continue;
}
}
public class CustomRequestHandler : RequestHandler
{
protected override IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
{
return new CustomResourceRequestHandler();
}
}
browser.RequestHandler = new CustomRequestHandler();
https://stackoverflow.com/questions/31250797/chromium-send-custom-header-info-on-initial-page-load-c-sharp
ChromiumWebBrowser cerf设置header
最新推荐文章于 2023-03-10 09:52:56 发布