【问题标题】:UserNamePasswordValidator catch exceptionUserNamePasswordValidator 捕获异常
【发布时间】:2014-04-04 21:25:28
【问题描述】:

我有一个UserNamePasswordValidator

 public class EmployeeValidator : UserNamePasswordValidator
 {
    public override void Validate(String userName, String password)
    {
        //...
        throw new MessageSecurityException("Username and password cannot be empty.");
        //...         
    }
 }

ViewModel

private void Login()
{
     try
     {
          _cl.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
          _cl.ClientCredentials.UserName.UserName = UserName;
          _cl.ClientCredentials.UserName.Password = Password;
          _cl.Login(UserName)
     }
     catch
     {  /*...*/  }
}

问题是,我无法捕捉到异常。我做错了什么?

【问题讨论】:

  • 您是否启用了 MessageSecurity?在您的绑定中配置?你在使用服务吗?

标签: c# wcf wcf-security


【解决方案1】:

启动 fiddler,我打赌代码是 501(我可能已经过了 500 年了),然后搜索如何在 wcf 中重写错误代码。

如果不是 501,那么您的连接将不会中止,您可能能够正确处理错误(故障)

【讨论】:

    猜你喜欢
    • 2010-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-24
    • 2010-09-28
    • 2017-08-18
    相关资源
    最近更新 更多