• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 421
  • Last Modified:

Can .NET role name have spaces in it


Can a Role name have spaces in it? At the moment I always name my Roles without such as 'NewsEditor'. Can it be 'News Editor' without errors? Also, is there a best practice for formatting the name of a Role?

Thanks for your time with this.
1 Solution
Rolenames may not be empty or contain commas. Anything else shorter than 255 characters should be fine.
Role name can have spaces but should not have commas.

System.ArgumentException will be thrown if the role name is an empty string or contains a comma or longer than 256 characters.

System.ArgumentNullException will be thrown if role name is a null reference.

Role names are not case-sensitive.

Using spaces in role names may give you a meaningful description about the role. But you need to be careful when you use the role names in your code if it has spaces. Because if the role is defined with spaces in the database and if you missed the spaces somewhere in your code, then it will lead to some issues. My personal suggestion would be to avoid spaces.

Maheshwar RSoftware DeveloperCommented:

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now