System.InvalidOperationException: The AuthorizationPolicy named: 'Roles=RegisteredUser' was not found.

1ogrenci (11) 2 ay önce sordu

Arkadaşlar asp.net ve angular ile deneme yapıyorum. kullanıcı girişi yaptım. Bi sayfaya yetki verdim ama şöyle bir hata veriyor System.InvalidOperationException: The AuthorizationPolicy named: 'Roles=RegisteredUser' was not found. Sebebi ne olabilir?

Toplam 1 cevap


alattin (17014) 2 ay önce cevapladı

Authorize ifadesini yanlış yazmışsın. Şu hatalı yazım

  [Authorize("Roles=Administrator")]

Doğrusu şu şekilde olmalı:

  [Authorize(Roles="Administrator")]

Yani Roles ifadesi tırnak içinde olmamalı.  Bu sebepten AuthorizationPolicy named: 'Roles=RegisteredUser' was not found. hatası almışsın.

1ogrenci 2 ay önce

evet yanlış yazmışım :(