<defaultProxy enabled="true|false" useDefaultCredentials="true|false" <bypasslist> … </bypasslist> <proxy> … </proxy> <module> … </module> />
The remote server returned an error: (407) proxy authentication is required.
public class CustomUserProxy : IWebProxy { private WebProxy _webProxy; public CustomUserProxy(Uri uri) { _webProxy = new WebProxy(uri); } public ICredentials Credentials { get { return _webProxy.Credentials; } set { } } public Uri GetProxy(Uri destination) { return _webProxy.GetProxy(destination); } public bool IsBypassed(Uri host) { return _webProxy.IsBypassed(host); } /// <summary> /// , Credentials /// </summary> /// <param name="credentials"> </param> public void SetCredentials(ICredentials credentials) { _webProxy.Credentials = credentials; } }
Uri uriProxy = new Uri("http://myproxy.ent:808"); CustomUserProxy customProxy = new CustomUserProxy(uriProxy); customProxy.SetCredentials(new NetworkCredential("Login", "Password")); WebRequest.DefaultWebProxy = customProxy;
Source: https://habr.com/ru/post/279879/
All Articles