MVC 5 Role Based Authentication

前端 未结 1 2012
南笙
南笙 2021-02-11 04:01

I am trying to lock down our \"admin\" page to only admins using Asp.net Identity (we are building in MVC5). I can get [Authorize(Users=\"admin\")] to work but can not get [Auth

相关标签:
1条回答
  • 2021-02-11 04:40

    Have you specified in the web.config that you are going to use roles?

      <roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
          <providers>
            <clear />
            <add name="AspNetSqlRoleProvider" connectionStringName="DefaultConnection" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          </providers>
        </roleManager>
    
    0 讨论(0)
提交回复
热议问题