Trying to add an authentication filter to an ASP.NET Core 5 MVC action method and pass a parameter. However I'm unable to find a way to do this. This is the action filter code:
public class CheckUserPrivilege : IActionFilter
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISession _session;
public string PrivilegeCode { get; set; }
public CheckUserPrivilledge(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
_session = _httpContextAccessor.HttpContext.Session;
}
}
The parameter we need to pass is PrivilegeCode. Ideally want something like [CheckUserPrivilege("abc")] but when we try like so, I presume it also asks for the IHttpContextAccessor` parameter in the constructor.
Any help appreciated.
