添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I see the error 412 Precondition failed with the below code. It used to work until 1st of April 2021. It started failing from 2nd April 2021.

var response = new WebClient().DownloadString("http://www.dce.com.cn");

Please can someone help me with this?

Thanks in advance

Seemingly dce.com.cn changed something. Perhaps they check the User-Agent header now. Perhaps it's something else. – ProgrammingLlama Apr 9, 2021 at 5:55 Weirdly this works from the browser. Only doesn't work from c# code. I captured the request from fiddler. Tried the same request headers from c# as well. Still seeing the same 412 error. – user965291 Apr 9, 2021 at 8:21 *** Fiddler Request *** POST dce.com.cn/publicweb/quotesdata/dayQuotesEn.html HTTP/1.1 Connection: keep-alive Content-Length: 69 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9 – user965291 Apr 9, 2021 at 8:26 Yes @Julian-Reschke. The actual URI we use is in the fiddler request. To make it simple initially I provided the base URI. – user965291 Apr 9, 2021 at 12:20

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.