8

Using MVC Core with ASP.NET Identity I would like to change the defaults error messages of ValidationSummary that arrived from Register action. Any advice will be much appreciated.

ASP.NET Core Register Action

2
  • You can change this messages from model class Commented Aug 16, 2016 at 5:55
  • You should be able to change these Error Messages in the AccountViewModel.cs with the Property ErrorMessage = "..." in a DataAnnotation. Commented Aug 16, 2016 at 6:51

1 Answer 1

17

You should override methods of IdentityErrorDescriber to change identity error messages.

public class YourIdentityErrorDescriber : IdentityErrorDescriber
{
    public override IdentityError PasswordRequiresUpper() 
    { 
       return new IdentityError 
       { 
           Code = nameof(PasswordRequiresUpper),
           Description = "<your error message>"
       }; 
    }
    //... other methods
}

In Startup.cs set IdentityErrorDescriber

public void ConfigureServices(IServiceCollection services)
{
    // ...   
    services.AddIdentity<ApplicationUser, IdentityRole>()
            .AddErrorDescriber<YourIdentityErrorDescriber>();
}

The answer is from https://stackoverflow.com/a/38199890/5426333

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.