I am creating an ASP.NET Core Web API project. I want to define an attribute (for example ExampleAttribute) and access the HttpContext in it and doing some action and finally return an ObjectResult if necessary, or continue.
I don't know if I am doing it right or not, but I want to define an attribute in this way:
public class DeveloperTaskAttribute : Attribute
{
// using HttpContext and doing some action
// I will returning BadRequest("") if necessary
// or continue...
}
And I'm trying to use this attribute on this endpoint:
[HttpGet]
[ExampleAttribute] // using attribute
public IActionResult EndPoint1()
{
// doing some action in endpoint1
}
How can I do this?
Thanks for any help.