What's the right way to handle a proxy autocon

2019-04-08 11:01发布

I'm using .NET 2.0 to make a simple webservice call. From most machines, I don't need to do anything special. However, one client is on a corporate network that uses a proxy autoconfig script. Just about everything I can find (e.g. http://msdn.microsoft.com/en-us/magazine/cc300743.aspx#S3) tells me that I shouldn't need to do anything. .NET will read the proxy settings from the registry and "just work". Yeah right.

If the client uses their browser to visit the webservice URL first, then my webservice call does work. However, after some period of time the webservice calls stop working with a 407 (Proxy Authentication Required) error.

I've tried explicitly setting the proxy (as suggested by Get Proxy configuration before accessing an external webservice (.NET 2.0)), but haven't had any luck.

I found this MS knowledgebase article with information on calling WinHttpGetProxyForUrl in WinHTTP.DLL. If I pull the autoconfigurl setting out of the registry and use it in a call to WinHttpGetProxyForUrl, it seems to work, but it just seems wrong to have to go there. Does anyone know the "right way" to get .NET to use the default IE proxy autoconfig script? Thanks.

标签: .net proxy
1条回答
Rolldiameter
2楼-- · 2019-04-08 11:37

Whether or not it's supposed to work, I'd not to depend on auto-config scripts for web services. Those are meant to configure proxy services for web browsers.

The IT organization should figure out which proxy is to be used on that particular machine, for that particular web service, and set it in the config file.

查看更多
登录 后发表回答