views:

64

answers:

1

I have a membership provider and i have several reasons a login can fail that I need to relay to the user.

Everything I have read involves a lot of code.

Is there an easy way to do this?

+5  A: 

Sure.

You can put your out-of-band data into the context when in your provider and then pick it up in the error handler of your login control to set the failure text.

public override bool ValidateUser(string username, string password)
{
   // in membership provider
   HttpContext.Current.Items["loginFailureReason"] = "Locked Out";
   return false;
}

// in login codebehind
protected void Login1_LoginError(object sender, EventArgs e)
 {
     Login1.FailureText = (string) HttpContext.Current.Items["loginFailureReason"];
 }
Sky Sanders