dotnet Core, custom attribute filter

Hi question about dotnet core,

what is the new approach on implementing custom attribute, do i need to register it on Startup?

Here’s my sample code

public class TokenAuthAttribute : Attribute, IAuthenticationFilter

{

public bool AllowMultiple => true; 

public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) { ... } 

protected Task<IPrincipal> AuthenticatePublicJWToken(string jwtoken) { 

} 

public Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken) { 

} 

}

___________________________________________________

[TokenAuth]

[HttpPost(“api/route”, Name = “name”)]

public IActionResult myClass()

{

return Ok(); 

}

submitted by /u/fijih
[link] [comments]

Leave a Reply