Table of Contents

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 HttpContext

HttpContext that we're using to write the response.

title string

Error type message.

reason string

The detailed reason for the denied request. (default: "Access denied")

statusCode int?

The HTTP status code for the error. (default: 403)

cancellationToken CancellationToken

CancellationToken for the async write.

Returns

ValueTask