How to change error message in ASP.NET Identity -


i have 1 question. i'm trying change error message in identity asp .net , don't know how it. want change error message - "login taken". createasync method return error message. please me.

the microsoft.aspnet.identity.usermanager<tuser> class has public property called uservalidator of type iidentityvalidator<tuser>. constructor usermanager sets property instance of microsoft.aspnet.identity.uservalidator<tuser>. error messages see when calling createasync come resources embedded in microsoft.aspnet.identity.dll , added identityresult inside uservalidator.

you provide own implementation of iidentityvalidator<tuser>, single method signature: task<identityresult> validateasync(tuser item). you'd have implement own validations, you'd have control on messages come out. like:

public class uservalidator : iidentityvalidator<applicationuser> {     public async task<identityresult> validateasync(applicationuser item)     {         if (string.isnullorwhitespace(item.username))         {             return identityresult.failed("really?!");         }          return identityresult.success;     } } 

the default uservalidator class performs 3 basic validations keep in mind if roll own:

  1. username not null or whitespace
  2. username alphanumeric
  3. username not duplicate

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -