Class AspNetCoreCspNonceService
ASP.NET Core implementation of ICspNonceService that generates and caches a cryptographically secure nonce per HTTP request.
Inheritance
object
Namespace: Umbraco.Cms.Web.Common.Security
Assembly: Umbraco.Web.Common.dll
Syntax
public class AspNetCoreCspNonceService : ICspNonceService
Constructors
View SourceAspNetCoreCspNonceService(IHttpContextAccessor)
Initializes a new instance of the AspNetCoreCspNonceService class.
Declaration
public AspNetCoreCspNonceService(IHttpContextAccessor httpContextAccessor)
Parameters
| Type | Name | Description |
|---|---|---|
| IHttpContextAccessor | httpContextAccessor | The HTTP context accessor. |
Methods
View SourceGetNonce()
Gets the CSP nonce for the current request (generates once, caches per-request). Returns null if no HTTP context is available.
Declaration
public string? GetNonce()
Returns
| Type | Description |
|---|---|
| string | The CSP nonce value, or null if no HTTP context is available. |