Skip to main content

Definition

Assembly: CloudNimble.BlazorEssentials.Server.dll Namespace: CloudNimble.BlazorEssentials.Server.Middleware Inheritance: System.Object

Syntax

CloudNimble.BlazorEssentials.Server.Middleware.CrossOriginIsolationMiddleware

Summary

Middleware that adds Cross-Origin Isolation headers (COOP and COEP) to responses. These headers are required for features like SharedArrayBuffer and high-resolution timers, which are needed by WASM libraries like TursoDb that use OPFS (Origin Private File System).

Remarks

<strong>Warning:</strong> Enabling cross-origin isolation may break third-party scripts, iframes, and CDN resources that are not configured to work in an isolated context. Test thoroughly before enabling in production. Headers added:
  • Cross-Origin-Opener-Policy: same-origin - Isolates the browsing context
  • Cross-Origin-Embedder-Policy: require-corp - Requires all resources to explicitly grant permission

Examples

// In Program.cs
app.UseCrossOriginIsolation();

// Or with options
app.UseCrossOriginIsolation(options =&gt;
{
    options.CoopPolicy = "same-origin";
    options.CoepPolicy = "require-corp";
    options.ExcludePaths.Add("/api/");
});

Constructors

.ctor

Initializes a new instance of the CrossOriginIsolationMiddleware class.

Syntax

public CrossOriginIsolationMiddleware(Microsoft.AspNetCore.Http.RequestDelegate next, CloudNimble.BlazorEssentials.Server.Middleware.CrossOriginIsolationOptions options = null)

Parameters

NameTypeDescription
nextMicrosoft.AspNetCore.Http.RequestDelegateThe next middleware in the pipeline.
optionsCloudNimble.BlazorEssentials.Server.Middleware.CrossOriginIsolationOptions?Configuration options for cross-origin isolation.

.ctor Inherited

Inherited from object

Syntax

public Object()

Methods

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

InvokeAsync

Invokes the middleware to add cross-origin isolation headers.

Syntax

public System.Threading.Tasks.Task InvokeAsync(Microsoft.AspNetCore.Http.HttpContext context)

Parameters

NameTypeDescription
contextMicrosoft.AspNetCore.Http.HttpContextThe HTTP context.

Returns

Type: System.Threading.Tasks.Task A task representing the asynchronous operation.

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?