[英]Why an application working in Windows7(.net 3.5)is not working in Win8(.net4.5)
[英]NTLM authentication not working after convertion to .net3.5 from .net4.5
以下代碼是webservice中的post方法。 問題:NTML身份驗證在.net Framework 4.5中工作正常,但我想在.net Framework 3.5中運行代碼以使項目與Windows XP兼容。
錯誤:未經授權的401
try
{
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender2, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
};
WebRequest request = WebRequest.Create("http://192.168.100.254"+urldata);
request.Method = "POST";
//NTML authentication
CredentialCache cc = new CredentialCache();
cc.Add(
new Uri("http://192.168.100.254"),
"NTLM",
new NetworkCredential("admin", "mnjkl"));
request.Credentials = cc;
byte[] byteArray = Encoding.UTF8.GetBytes(data);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
return responseFromServer;
}
catch (Exception Ex)
{
throw Ex;
}
請任何了解.net3.5中的NTLM身份驗證的人幫助我。 謝謝。
我也有同樣的問題。 我能夠通過更改突出顯示的本地組策略來解決這些問題,所有您需要做的就是右鍵單擊該策略,然后單擊屬性,您需要取消選中使用128位ssl 本地組策略中的設置的屏幕快照
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.