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

前端 未结 4 951
日久生厌
日久生厌 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条回答
  •  Happy的楠姐
    2020-12-11 20:13

    Try setting the UserAgent header:

    string _UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
    client.Headers.Add(HttpRequestHeader.UserAgent, _UserAgent);
    

提交回复
热议问题