public class MyRequestHandler : DefaultRequestHandler { public static readonly string VersionNumberString = String.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}", Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion); public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { Uri url; if (Uri.TryCreate(request.Url, UriKind.Absolute, out url) == false) { return CefReturnValue.Cancel; } var headers = request.Headers; headers["Authorization"] =Program.Token; //傳遞進去認證Token request.Headers = headers; return CefReturnValue.Continue; } }
而後在使用的時候,就能夠獲取到Header的內容了。ide
…… private ChromiumWebBrowser browser; …… browser.RequestHandler = new MyRequestHandler(); ……