首页 > 代码库 > cefsharp设置网页接受语言Accept-Language

cefsharp设置网页接受语言Accept-Language

1.设置浏览器的请求控制器

 webView.RequestHandler = RequestHandler; 

2.新建RequestHandler类继承IRequestHandler接口,实现方法OnBeforeResourceLoad

   /// <summary>        /// 资源加载之前事件(请求还未进入服务器)        /// </summary>        /// <param name="browser"></param>        /// <param name="requestResponse"></param>        /// <returns></returns>        public bool OnBeforeResourceLoad(IWebBrowser browser, IRequestResponse requestResponse)        {            IDictionary<string, string> headers = requestResponse.Request.GetHeaders();            headers.Add("Accept-Language", "zh,zh-cn,zh-tw");            requestResponse.Request.SetHeaders(headers);                    return false;        }