Skip to content

ActionResultExtensions Class

Composable post-processing helpers for Microsoft.AspNetCore.Mvc.ActionResult instances returned from OIDC controllers. Each extension wraps the original result so it still executes its own pipeline, while attaching headers, cookies, or formatting OAuth errors as RFC-compliant HTTP responses.

C#
public static class ActionResultExtensions

Inheritance System.Object → ActionResultExtensions

Methods

ActionResultExtensions.Format(this OidcError, int, string) Method

Formats an OidcError as an appropriate HTTP error response per RFC 6750 Section 3. Bearer token errors (invalid_token) return HTTP 401 with only a WWW-Authenticate header and no response body. Scope errors (insufficient_scope) return HTTP 403 with the header. Client authentication failures (invalid_client) return HTTP 401 with a Basic challenge and the JSON error body per RFC 6749 Section 5.2. All other errors use the specified fallback status code with a JSON body.

C#
public static Microsoft.AspNetCore.Mvc.ActionResult Format(this Abblix.Oidc.Server.Common.OidcError error, int fallbackStatusCode, string? realm=null);

Parameters

error OidcError

The OIDC error to format.

fallbackStatusCode System.Int32

The HTTP status code to use for non-token errors.

realm System.String

Optional realm value identifying the protection space (typically the issuer URI).

Returns

Microsoft.AspNetCore.Mvc.ActionResult
An Microsoft.AspNetCore.Mvc.ActionResult with the appropriate status code and headers.

ActionResultExtensions.Format(this OidcError, int, string, IEnumerable<string>, bool) Method

Formats an OidcError as an HTTP error response that advertises the DPoP scheme (RFC 9449 §7.1) on the WWW-Authenticate header, optionally alongside the Bearer scheme. UseDPoPNonceError additionally emits the DPoP-Nonce response header so the client can echo the freshly issued nonce on retry.

C#
public static Microsoft.AspNetCore.Mvc.ActionResult Format(this Abblix.Oidc.Server.Common.OidcError error, int fallbackStatusCode, string? realm, System.Collections.Generic.IEnumerable<string> dpopAlgs, bool advertiseBearer);

Parameters

error OidcError
fallbackStatusCode System.Int32
realm System.String
dpopAlgs System.Collections.Generic.IEnumerable<System.String>
advertiseBearer System.Boolean

Returns

Microsoft.AspNetCore.Mvc.ActionResult

ActionResultExtensions.WithAntiFramingHeaders(this ActionResult) Method

Decorates a self-rendered HTML result (the form_post auto-submit page) with the anti-framing headers so it can never be embedded in another origin's frame (clickjacking defense, RFC 9700 Section 4.16). The check_session page cannot use this path: its CSP carries a per-request nonce generated inside the result, so it sets the header itself.

C#
public static Microsoft.AspNetCore.Mvc.ActionResult WithAntiFramingHeaders(this Microsoft.AspNetCore.Mvc.ActionResult innerResult);

Parameters

innerResult Microsoft.AspNetCore.Mvc.ActionResult

The HTML-producing Microsoft.AspNetCore.Mvc.ActionResult to protect.

Returns

Microsoft.AspNetCore.Mvc.ActionResult
A decorated Microsoft.AspNetCore.Mvc.ActionResult that emits the anti-framing headers.

ActionResultExtensions.WithAppendCookie(this ActionResult, string, string, CookieOptions) Method

Decorates an Microsoft.AspNetCore.Mvc.ActionResult to append a cookie to the response.

C#
public static Microsoft.AspNetCore.Mvc.ActionResult WithAppendCookie(this Microsoft.AspNetCore.Mvc.ActionResult innerResult, string name, string value, Microsoft.AspNetCore.Http.CookieOptions options);

Parameters

innerResult Microsoft.AspNetCore.Mvc.ActionResult

The Microsoft.AspNetCore.Mvc.ActionResult to decorate.

name System.String

The name of the cookie to append.

value System.String

The value of the cookie.

options Microsoft.AspNetCore.Http.CookieOptions

The Microsoft.AspNetCore.Http.CookieOptions to configure the cookie.

Returns

Microsoft.AspNetCore.Mvc.ActionResult
A decorated Microsoft.AspNetCore.Mvc.ActionResult that appends the specified cookie.

ActionResultExtensions.WithAppendHeader(this ActionResult, string, IEnumerable<string>) Method

Decorates an Microsoft.AspNetCore.Mvc.ActionResult to append each value as a separate header line. Use when the wire form expects multiple header lines under the same name (e.g. RFC 9449 §7.1 dual WWW-Authenticate emission for DPoP and Bearer); plain WithHeader(this ActionResult, string, string) overwrites instead of appending.

C#
public static Microsoft.AspNetCore.Mvc.ActionResult WithAppendHeader(this Microsoft.AspNetCore.Mvc.ActionResult innerResult, string name, System.Collections.Generic.IEnumerable<string> values);

Parameters

innerResult Microsoft.AspNetCore.Mvc.ActionResult
name System.String
values System.Collections.Generic.IEnumerable<System.String>

Returns

Microsoft.AspNetCore.Mvc.ActionResult

ActionResultExtensions.WithDeleteCookie(this ActionResult, string, CookieOptions) Method

Decorates an Microsoft.AspNetCore.Mvc.ActionResult to delete a cookie from the response.

C#
public static Microsoft.AspNetCore.Mvc.ActionResult WithDeleteCookie(this Microsoft.AspNetCore.Mvc.ActionResult innerResult, string name, Microsoft.AspNetCore.Http.CookieOptions options);

Parameters

innerResult Microsoft.AspNetCore.Mvc.ActionResult

The Microsoft.AspNetCore.Mvc.ActionResult to decorate.

name System.String

The name of the cookie to delete.

options Microsoft.AspNetCore.Http.CookieOptions

The Microsoft.AspNetCore.Http.CookieOptions to configure the deletion of the cookie.

Returns

Microsoft.AspNetCore.Mvc.ActionResult
A decorated Microsoft.AspNetCore.Mvc.ActionResult that deletes the specified cookie.

ActionResultExtensions.WithHeader(this ActionResult, string, string) Method

Decorates an Microsoft.AspNetCore.Mvc.ActionResult to append a header to the response.

C#
public static Microsoft.AspNetCore.Mvc.ActionResult WithHeader(this Microsoft.AspNetCore.Mvc.ActionResult innerResult, string name, string value);

Parameters

innerResult Microsoft.AspNetCore.Mvc.ActionResult

The Microsoft.AspNetCore.Mvc.ActionResult to decorate.

name System.String

The name of the header to append.

value System.String

The value of the header.

Returns

Microsoft.AspNetCore.Mvc.ActionResult
A decorated Microsoft.AspNetCore.Mvc.ActionResult that appends the specified header.