How to write AuthorizeAttribute if a role contains space

后端 未结 3 1297
囚心锁ツ
囚心锁ツ 2021-01-05 17:21

I am using MVC3/4. But it is just a general question in authorization.

One of the role I have is named \"Trip Leader\" in the database, which contains a space.

3条回答
  •  时光说笑
    2021-01-05 18:09

    Try this:

    [Authorize(Roles="Trip Leader")]
    [Authorize(Roles="Administrator")]
    

    EDIT: The above code requires the user to fulfill both roles. If you are looking for an either/or authorization, try this:

    [Authorize(Roles="Trip Leader, Administrator")]
    

提交回复
热议问题