C# htmlagility, getting exception when i add header in following code
问题 I'm getting exception when i run this code Exception "header must be modified using the appropriate property or method." HtmlAgilityPack.HtmlWeb web = new HtmlWeb(); web.UserAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"; web.PreRequest += (request) => { request.Headers.Add("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); request.Headers.Add("Accept-Language", "de-DE"); return true; };