【发布时间】:2014-04-30 07:38:38
【问题描述】:
我正在编写一个非常简单的带有用户名/密码身份验证的 WCF 服务。我的用户名/密码验证器代码如下所示:
public class InvoiceServiceUserValidation : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
{
throw new SecurityTokenException("Username and password required");
}
if (InvoiceServiceHelper.AuthenticateUser(userName, password)) return;
throw new FaultException("Could not authenticate - Unknown reason");
}
}
如果我提供正确的用户名和密码,一切正常,操作继续。当我提供错误的密码时,hover,异常永远不会返回,所以我的客户只是在它超时之前呆在那里等待。
我已经调试过,所以我知道当它出错时,实际上已经到达了带有“throw new FaultException”的行,但仍然没有给客户答复。
非常感谢您的帮助
【问题讨论】:
标签: c# wcf wcf-security