C# 请求通过代理时发生身份验证错误
我有以下代码通过代理服务器发出web请求。我在服务器上使用wireshark嗅探网络流量,发现在发出请求时出现以下错误: 无法验证您的凭据:“缺少凭据。”。在验证您的凭据之前,将不允许您访问。\n 身份验证应通过NTLM运行 有人能帮忙吗C# 请求通过代理时发生身份验证错误,c#,asp.net,.net,networking,proxy,C#,Asp.net,.net,Networking,Proxy,我有以下代码通过代理服务器发出web请求。我在服务器上使用wireshark嗅探网络流量,发现在发出请求时出现以下错误: 无法验证您的凭据:“缺少凭据。”。在验证您的凭据之前,将不允许您访问。\n 身份验证应通过NTLM运行 有人能帮忙吗 //... CALL THE CODE string url = String.Format("http://currencyconverter.kowabunga.net/converter.asmx/GetCultureInfo?Curre
//... CALL THE CODE
string url = String.Format("http://currencyconverter.kowabunga.net/converter.asmx/GetCultureInfo?Currency={0}", CurrencyTo.Text);
returnValue = GetResponseValue(url);
//...
private static string GetResponseValue(string url)
{
WebRequest request = InitialiseWebRequest(url);
WebResponse response = request.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
XDocument xmlDoc = new XDocument();
xmlDoc = XDocument.Parse(sr.ReadToEnd());
string returnValue = xmlDoc.Root.Value;
return returnValue;
}
private static WebRequest InitialiseWebRequest(string url)
{
WebRequest request = WebRequest.Create(url);
if (!string.IsNullOrEmpty(ConfigurationSettings.AppSettings["proxyLogin"]))
{
string proxyUrl = ConfigurationSettings.AppSettings["proxyUrl"];
if (!string.IsNullOrEmpty(ConfigurationSettings.AppSettings["proxyPort"]))
{
proxyUrl += ":" + ConfigurationSettings.AppSettings["proxyPort"];
}
WebProxy proxy = new WebProxy(proxyUrl);
// Create a NetworkCredential object and associate it with the Proxy property of request object.
proxy.Credentials = new NetworkCredential(ConfigurationSettings.AppSettings["proxyLogin"], ConfigurationSettings.AppSettings["proxyPassword"]);
NetworkCredential networkCredential = new NetworkCredential(ConfigurationSettings.AppSettings["proxyLogin"], ConfigurationSettings.AppSettings["proxyPassword"]);
CredentialCache credentialCache = new CredentialCache();
credentialCache.Add(new Uri(url), "NTML", networkCredential);
request.Credentials = credentialCache;
request.Proxy = proxy;
return request;
}
return request;
}
事实证明,用户名带有域前缀,密码过期,配置中没有更新
经过一整天的努力,我终于有了一个新的机会。结果是用户名加了域名前缀,密码过期了,配置中没有更新
经过一整天的观察,我发现了一个明显的问题。当你在嗅探时,你是否注意到正确的凭据(我猜用户名/密码是你如何验证的)是否会进入代理?我该如何检查?我假设由于安全原因,无法检查用户名/密码。当您进行嗅探时,是否注意到正确的凭据(我猜用户名/密码是如何进行身份验证的)是否将发送到代理?我如何进行检查?我假设由于安全原因,无法检查用户名/密码