Domain property of NetworkCredential class

  • Thread starter Thread starter DT
  • Start date Start date
D

DT

I'm trying to provide flexible support of various HTTP proxy servers in my
web client app, and need to understand in what situations the various proxy
authentication properties are used...

Specifically, what should the Domain property of the NetworkCredential class
be set to when using WebProxy?

I'm testing against an Apache 2 proxy server, which is set to basic
authentication, with the name of its realm set to "Proxy Server".

When I don't set the Domain property of my NetworkCredential object, my
WebRequest.GetResponse works OK.

But when I set Domain to "Proxy Server" (which I expected to be required)...
I get HTTP 407.

So what exactly does the Domain specify? When is it used?

Code fragment below.

Thanks,

David Thom

Dim myWebRequest As WebRequest =
WebRequest.Create("http://www.microsoft.com")

Dim myWebProxy = New WebProxy

myWebProxy.Address = New Uri(http://10.0.2.6) ' the Apache proxy server

Dim myCredentials As New NetworkCredential

myCredentials.UserName = "user"

myCredentials.Password = "password"

' myCredentials.Domain = "Proxy Server" ' GetResponse works if I don't set
Domain property

myWebProxy.Credentials = myCredentials

myWebRequest.Proxy = myWebProxy

Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
 
Back
Top