I am using asp.net Identity for authorization and authentication. I tried creating a user name with Hebrew letters but it didn't work.
With the old Membership I was able to use Hebrew characters for user names. Is it possible with Identity to use non-Latin characters?
I think you can attempt to do something like this:
Create a new Custom user validator to do your own custom validation( You can use a regex as well for validations):
public class CustomUserValidator<TUser> : IIdentityValidator<TUser>
where TUser : class, Microsoft.AspNet.Identity.IUser
{
public CustomUserValidator(UserManager<TUser> manager)
{
_manager = manager;
}
public async Task<IdentityResult> ValidateAsync(TUser item)
{
// Your custom validation here
}
}
and then when you are creating your application user manager you can set the Default user validator to an instance of this new validator class:
manager.UserValidator = new CustomUserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = true
};
[NOTE:] default validator is like:
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = false,
};