System.Net.WebClient request gets 403 Forbidden but browsers do not with Apache servers

前端 未结 4 955
日久生厌
日久生厌 2020-12-11 19:24

An odd one, I\'m trying to read the section of a lot of different websites out there, and one particular type of server, Apache, sometimes gives the code 403 fo

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 20:03

    I had a similar problem and below setting solved it

    Client.Headers["Accept"] = "application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
    Client.Headers["User-Agent"] ="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDC)";
    

提交回复
热议问题