Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

.Net Core Membership Roles

$
0
0

I have a project that uses windows authentication (company’s intranet)

I use AspNetUsers, AspNetRoles and AspNetUserRoles tables I create two roles, User and Admin, and add users into these tables,

 

I have a MaintainUsers page that is accessed by only users with Admin role, See code below

[Authorize(Roles = "Admin")] public class MaintainUsersController : BaseController

I assign Admin role to myself. I get access denied by this page.

Then I use User.IsInRole("Admin") to test if I have Admin role, but the result is false so I do not have Admin, but in the tables, I have the Admin role

What is wrong or miss something?

I used Membership in web form and MVC for windows authentication applications in the past time.

I do not have this problem. I was able to add domain/userid as username to the table, but unable to do on the  AspNetUsers table, this is only difference between what I did in the past time and now

 Thanks,

 


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>