× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

How to localize ASP.NET Identity UserName and Password error messages?

Cristian Lupașcu
Mar 04, 2015
<p>I ran into the same problem and found a quick-and-dirty workaround. I looked inside the <code>Microsoft.AspNet.Identity.Core</code> assembly using DotPeek (I assume any C# decompiler will do) and found two classes that are responsible for such messages:</p> <ul> <li><code>Microsoft.AspNet.Identity.UserValidator&lt;TUser&gt;</code> (UserName-related)</li> <li><code>Microsoft.AspNet.Identity.MinimumLengthValidator</code> (Password related)</li> </ul> <p>These classes do not contain any external references (other than the string resources that you want to replace anyway), so re-implementing them in your own code should be fairly straightforward.</p> <p>After doing so, don't forget to properly use them in your <code>UserManager</code>:</p> <pre><code>UserManager.UserValidator = new MyCustomUserValidator&lt;MyUserType&gt;(UserManager); UserManager.PasswordValidator = new MyCustomMinimumLengthValidator(6); </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/19961648/How%20to%20localize%20ASP.NET%20Identity%20UserName%20and%20Password%20error%20messages?/22259844">Stack Overflow</a>.</p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus