WCF:SecurityNegotiationException 调用方未由服务进行身份验证
WCF:SecurityNegotiationException 调用方未由服务进行身份验证
扫一扫加作者微信
System.ServiceModel.Security.SecurityNegotiationException
HResult=0x80131501
Message=调用方未由服务进行身份验证。
Source=mscorlib
StackTrace:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
内部异常 1:
FaultException: 无法满足对安全令牌的请求,因为身份验证失败。
错误原因:
当客户端凭据验证方式为Basic/Windows时,需要验证客户端(调用方)的用户及密码。
解决方案(1) :凭据验证=Windows
C# Code:
//重要!!!Windows身份认证-需要的本地Windows认证的用户名及密码
var identity = new System.Net.NetworkCredential("wcfuser", "123456");
//Windows身份认证信息
myChannelFactory.Credentials.Windows.ClientCredential = identity;
//来源:C/S框架网 | www.csframework.com | QQ:23404761
var identity = new System.Net.NetworkCredential("wcfuser", "123456");
//Windows身份认证信息
myChannelFactory.Credentials.Windows.ClientCredential = identity;
//来源:C/S框架网 | www.csframework.com | QQ:23404761
解决方案(2) :凭据验证=Basic
C# Code:
//重要!!!设置BASIC认证-需要的本地Windows认证的用户名及密码
myChannelFactory.Credentials.UserName.UserName = "wcfuser";
myChannelFactory.Credentials.UserName.Password = "123456";
//来源:C/S框架网 | www.csframework.com | QQ:23404761
myChannelFactory.Credentials.UserName.UserName = "wcfuser";
myChannelFactory.Credentials.UserName.Password = "123456";
//来源:C/S框架网 | www.csframework.com | QQ:23404761
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网