I've written simple WCF service using netTcpBinding and security mode="Message" and clientCredentialType="UserName". Everythink works fine when I pass valid username and password, session is established the way I wanted. However when the credentials are wrong exception is thrown though I can't catch it in my client application in try catch block. Did anyone have the same problem ? Here is my custom validator...
public class UserValidator : UserNamePasswordValidator
{
static int counter = 0;
public override void Validate(string userName, string password)
{
++counter;
Console.WriteLine(counter.ToString() + " " + DateTime.Now.ToShortTimeString());
if (userName != "test" || password != "test")
throw new FaultException("Bad username or password");
//throw new SecurityTokenException();
}
}