proxyhttpwebrequestwebrequestproxy-authentication

WebRequest is not able to validate invalid proxy credentials after validating valid credentials in vb.net


I'm validating proxy credentials using WebRequest.DefaultWebProxy. After giving valid credentials when I'm using invalid credentials it also works fine. so it is not validating proxy credentials here.

here is my code.

Dim webProxy = New Net.WebProxy(Uri)
webProxy.Credentials = New Net.NetworkCredential("userName", "Password")
WebRequest.DefaultWebProxy = webProxy 

Solution

  • I reproduced this issue successfully and it seems like setting the Proxy at global level using WebRequest.DefaultWebProxy is caching the credentials for some time even after setting it to Nothing.

    I couldn't find a solution to this problem but I can suggest you a workaround. What you can do is to create a separate utility(executable file) and pass your credentials while invoking this utility. By this approach you will not face any issue with the caching and you will receive the correct response.

    Please try if it works for you.