i tried below code to resolve the proxy authentication issue. But still the issue is persist. Note: Some networks without using Proxy, it is working fine.
var INI = new IniFile(@"Settings.ini");
String scredUserName = INI.Read("UserName", "Credentials");
String sPassword = INI.Read("Password", "Credentials");
String sAPIKey = INI.Read("APIKey", "Credentials");
string sUserNamePassword = scredUserName + ":" + sPassword;
byte[] byteUserNamePassword = System.Text.ASCIIEncoding.ASCII.GetBytes(sUserNamePassword);
string encodedUserNamePassword = System.Convert.ToBase64String(byteUserNamePassword);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
encodedUserNamePassword);
client.DefaultRequestHeaders.Add("aw-tenant-code", sAPIKey);
String sProxyUserName = INI.Read("UserName", "Proxy Authentication");
String sProxyPassword = INI.Read("Password", "Proxy Authentication");
string sProxyUserNamePassword = sProxyUserName + ":" + sProxyPassword;
byte[] byteProxyUserNamePassword = System.Text.ASCIIEncoding.ASCII.GetBytes(sProxyUserNamePassword);
string encodedProxyUserNamePassword = System.Convert.ToBase64String(byteProxyUserNamePassword);
client.DefaultRequestHeaders.Add("Proxy-Authorization", "Basic " + encodedProxyUserNamePassword);
Posting the answer for my questions:- I should have passed Proxy credentials along with proxy address.
WebProxy wbProxy = new WebProxy();
Uri newUri = new Uri(sProxyAddress);
wbProxy.Address = newUri;
wbProxy.Credentials = new NetworkCredential(sProxyUserName, sProxyPassword);
client.Proxy = wbProxy;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.