Can .NET role name have spaces in it

Posted on 2009-12-18
Last Modified: 2013-11-08

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.
Question by:MonCapitan
    LVL 12

    Expert Comment

    Rolenames may not be empty or contain commas. Anything else shorter than 255 characters should be fine.
    LVL 10

    Accepted Solution

    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.

    LVL 4

    Expert Comment

    by:Mahesh Reddy

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Xamarin 10 18
    varchar (max) 5 22
    Adding WebGrid Checkbox Column checked by default 3 13
    GridDataView 6 15
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now