简体   繁体   中英

The creator of this fault did not specify a Reason

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM