public static void SetNetworkCredentials( this WebClientProtocol client, string userName, string password, Uri customUrl = null) { if (client == null) { throw new ArgumentNullException(nameof(client)); } client.PreAuthenticate = true; var uri = customUrl == null ? new Uri(client.Url) : customUrl; var netCredential = new NetworkCredential(userName, password); ICredentials credentials = netCredential.GetCredential(uri, "Basic"); client.Credentials = credentials; }
/// <summary> /// /// </summary> /// <param name="protocol"></param> public void InitWebClientProtocol(WebClientProtocol protocol) { protocol.Timeout = (int)this.Timeout.TotalMilliseconds; }