HttpSendRequest return error 2

if you meet this issue, please read below post:

HttpSendRequest() will fail with an error code of 2 (ERROR_FILE_NOT_FOUND) when Windows/Internet Explorer is set to “Work offline” and the resource is not in the offline cache.

This doesn’t seem to effect .Net based HTTP clients or other web browsers like FireFox or Chrome making it not immediatly obvious if Internet Explorer is not the primary or default browser.

You can go back “online” by opening up Internet Explorer, going to the file menu (pressing Alt if it’s not visible), and unticking “Work offline”. After this, programmatic attempts to use WinInet will work correctly.

Note that Windows/Internet Explorer can get into this state accidentally if you set up dial up/VPN connections for testing or occasional use and its not set to “Never dial a connection”

See MSDN:

In offline mode, HttpSendRequest returns ERROR_FILE_NOT_FOUND if the resource is not found in the Internet cache.
what is offline mode?  

Note that Windows/Internet Explorer can get into this state accidentally if you set up dial up/VPN connections for testing or occasional use and its not set to “Never dial a connection”
[Elliot]  请注意,会随机偶然改动这个设置的哦,所以有点小恐怖,当你遇到问题的时候。必要的log是很需要的。

0
One comment to “HttpSendRequest return error 2”
  1. I feel that you are really angry about some PC guys asinkg you some stupid questions, right?Well, just forgive them. I feel really pretty on them, as they can’t use the best technology in the world. I was a PC guy, and I know how bad a PC is. Viruses, always slowing down, need a great resources…Why not a Mac?

Comments are closed.