Hi,
We have a commercial app that downloads data from various Web pages (not via
a Web Service, per se) and parses the data from the response. The code
below works fine most of the time but, in some corporate environments --
esp. those with Proxy servers -- the app fails to get the page. That is, it
isn't just that the app doesn't logon to the proxy but, in many cases, that,
as far as we can tell, the app makes a request using a non-existent or
non-functioning Internet connection, instead of another perfectly
functioning one on the same machine. So ... two problems and questions:
1. In cases of proxies, how do we detect and automatically use them? In
many cases, it appears that the code below fails to use them and the request
ends with an exception.
'URL is something like http://www.seattleavionics.com/
wr = CType(WebRequest.Create(URL), HttpWebRequest)
Resp = CType(wr.GetResponse(), HttpWebResponse)
2. In other cases, seemingly more likely when there is a Cisco VPN
connection (even if not active, just on the system) or the user has a
cell-phone data connection that uses Fourelle Venturi (used by Verizon's
mobile data solutions), the code above seems to simply get lost finding the
Internet and, although Internet Explorer has no trouble navigating the Web,
our app's Web requests eventually ends with a timeout. It's as if .Net
decided to use the wrong path to the Internet.
My understanding was that WebRequest would automatically use the same path
to the Internet as Internet Explorer would use. That is, we didn't have to
do anything and it should just magically work. Apparently this isn't the
case. Can someone clarify when we need to explicitly set the Proxy and when
we don't? And does anyone have any clue as to what is going on w/ #2?
Finally, does the code below look correct for manually setting a proxy?
Dim proxy As New Net.WebProxy(ProxyURL)
proxy.Credentials = New Net.NetworkCredential(Username, Password)
wr = CType(WebRequest.Create(URL), HttpWebRequest)
wr.Proxy = Proxy
Resp = CType(wr.GetResponse(), HttpWebResponse)
BTW -- If anyone is a pilot, free flight planning software for life if you
solve this one for us!
Thanks, Steve
www.seattleavionics.com