can I make use of user.IsInRole without using Membership?

后端 未结 4 1359
情深已故
情深已故 2021-01-14 15:52

I\'m using Forms authentication and I would like to make use of roles, can I somehow set the role of the user without Membership ?

4条回答
  •  旧时难觅i
    2021-01-14 16:31

    You don't need to implement a whole membership provider.

    Create your own Principal (which has the IsInRole method) and Identity.
    And then make sure your user object (HttpApplication.Context.User) is populated with your principal on each request.
    Done. Now the Authorize attribute will be talking to your principal.

提交回复
热议问题