Proxy credentials advice needed

  • Thread starter Thread starter George
  • Start date Start date
G

George

My desktop application (C# 2.0) works just fine and makes tons of
requests via WebRequest and WebClient objects. However, users that are
behind Proxy servers are not able to use the app. I'm sure my head is
not right on this issue and i need to seek advice.

First, I dont really understand why I (the programmer) have to worry
about these details - shouldnt this be somewhere below me on the ISO
stack? But that sounds like complaining, so I'll stop right there.

Second, I dont know how I should handle this. Am i required to fetch
credentials from the user and store it locally? Can i get default
credentials from the OS (or IE)? Note: I have tried this using
CredentialCache.DefaultCredentials, but the values are always blank.

Code snippets would be very helpful and appreciated, but I really
would like to get your opinion on how this should be handled -
conceptually. It just doesnt add up (for me) that every application
that makes web requests, needs to handle this for itself... it should
be down in the OS somewhere (IMHO).

Thanks in advance,

George
 
George,

No, it's really not below you. The mechanism that you are using for
generating http requests and responses is not something that is governed by
the system (.NET's implementation is from the ground up, and not through the
same mechanism that say IE uses) so you have to provide the ability to set
proxy information yourself if that is what is needed.

You basically have to get the credentials from the user (as well as the
address of the proxy sever, and any bypass addresses if you want to go that
far) and then use the WebProxy class to generate proxy information. You can
then set the Proxy property of your HttpWebRequest instance with the
WebProxy instance you created and the HttpWebRequest should use the proxy.
 
Back
Top