Class HttpContextExtensions
- Namespace
- Styra.Opa.AspNetCore
- Assembly
- Styra.Opa.AspNetCore.dll
public static class HttpContextExtensions
- Inheritance
-
HttpContextExtensions
- Inherited Members
Methods
WriteAccessDeniedResponse(HttpContext, string?, string?, int?, CancellationToken)
This extension method automates the process of returning customized Access Denied responses, optionally including a user-visible reason for the denial.
public static ValueTask WriteAccessDeniedResponse(this HttpContext context, string? title = null, string? reason = null, int? statusCode = null, CancellationToken cancellationToken = default)
Parameters
context
HttpContextHttpContext
that we're using to write the response.title
stringError type message.
reason
stringThe detailed reason for the denied request. (default:
"Access denied"
)statusCode
int?The HTTP status code for the error. (default:
403
)cancellationToken
CancellationTokenCancellationToken
for the async write.