简体   繁体   中英

How to customize ASP.NET Identity Core Username to allow special characters and space while registering

I would like to use some special characters like ø, in the user name. I have set the AllowOnlyAlphanumericUserNames = false , but i'm getting an error like as below.

User name tew-wer is invalid, can only contain letters or digits.

Can you please help me to solve this.

in startup.cs configure identity services to include allowed chars in user name:

services.AddIdentity<AppUser, AppRole>(ops =>
{
    //--- other code

    ops.User.AllowedUserNameCharacters = 
        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM