문제

I have set validation attributes in the model of my WCF service

[MinLength(6, ErrorMessage = "Password should be at least 6 characters long")]
public String Password { get; set; }

When this fails I get the exception in the title instead of the error message that I specified in the attribute. I am using the Validation Application Block for WCF.

The method definition is like this:

[OperationContract]
[FaultContract(typeof(ValidationFault))]
User updateUser(User user);

Can someone tell my what I am doing wrong?

Thanks

도움이 되었습니까?

해결책

When this fails I get the exception

You should specify the type of Fault you expect, so use

catch (FaultException<ValidationFault> ex)

다른 팁

I think you are not handling validation falut. Use validation fault at operation contract . You can refer this link.. http://www.codeproject.com/Articles/18667/Introduction-to-Validation-Application-Block-integ

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top