I have a WCF service hosted in IIS with a custom UserNamePasswordValidator. If the username / password fails validation, I’m throwing a custom Exception with a helpful message, i.e. “Invalid username or password”. When the client invokes a method and suppplies bad login credentials, the exception I get is a cryptic MessageSecurityException : “”An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.””
THe inner exception is null. My fear is that this exception can come up for other reasons besides bad authentication. Is there a way to have the service return my custom exception?
You need to throw a FaultException as outlined here.