R
R
RomanCheg2021-08-12 20:24:47
ASP.NET
RomanCheg, 2021-08-12 20:24:47

How to set authorization policy for ASP.NET core request?

I need to set an authorization policy for a request depending on the parameters of the request.
Using 'AuhtorizeAttribute' seems like a good idea at first glance, because you can set the 'Policy' property there, but there's no access to the 'HttpContext'.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2021-08-13
@yarosroman

Write your own middleware only.
As an example
https://docs.microsoft.com/en-us/aspnet/core/secur...

I
Ilya, 2021-08-13
@sarapinit

https://docs.microsoft.com/en-us/aspnet/core/secur... Seems
like it's possible to get httpcontext

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question