Using reCaptcha on IIS through a proxy

From Unofficial reCAPTCHA Wiki

Jump to: navigation, search

If you're using reCaptcha on a Windows Server running IIS, you're probably writing your code in either C# or ASP (VBScript). In either case you will more than likely encounter the following error when trying to connect to the reCaptcha server via XMlHttpRequest.

Even though you may have configured Interet Explorer to use a proxy, by default all other traffic to and from your server will be going direct.

If you use a URL that doesn't exist, or you are behind a firewall that blocks certain web sites, or the site is behind a firewall that blocks traffic to port 80 / 443, or you are using a proxy server, or the site requires authentication, you will receive this error:

msxml4.dll (0x80072EE7)
Server name or address could not be resolved

[edit] Using Proxycfg.exe

The next few sections will show you how to use some of the properties and methods associated with the ServerXMLHTTP object. Before showing these, it's important to note that you may run into a few problems associated with proxy servers. In cases where a proxy exists, Microsoft provides the proxycfg.exe utility that allows HTTP and HTTPS sites to be accessed through a proxy server. This utility also allows the proxy to be bypassed in cases where a direct server-to-server communication channel is desired.

The WinHTTP utilities come with all version of windows from 2000 onward.

Running the utility is as simple as going to the command prompt and typing something similar to the following:

proxycfg  p "http=http_proxy:port https=https_proxy:port" "<local>;*.microsoft.com"

This will cause all access to remote HTTP or HTTPS sites to go through the appropriate proxy server(s) while all local sites and all Microsoft sites will be accessed directly. In cases where a server does not go through a proxy you normally won't have to use this utility. However, to ensure sure that all remote servers are being accessed directly type the following at the command prompt:

proxycfg d

If you receive the evil Unspecified Error message when calling the ServerXMLHTTP's open() method after running proxycfg.exe, simply run the iisreset command (net stop w3svc and net start w3svc in NT) so that IIS is forced to reload the appropriate registry information.

[edit] See also

Using the WinHTTP Proxy Configuration Utility
http://msdn.microsoft.com/en-us/library/ms761351.aspx
About WinHTTP
http://msdn.microsoft.com/en-us/library/aa382925.aspx
Personal tools