HtmlCspExtensions class

namespace: Serenity.Web   assemblySerenity.Net.Web

Contains CSP related extension methods for HTML helpers and HTTP contexts.

public static class HtmlCspExtensions

Public Members

name description
static AddCspDirective(…) Adds a Content Security Policy directive to the current HTTP context items. (3 methods)
static AddCspScriptUrl(…) Adds a Content Security Policy script-src directive for the given URL and returns the URL. This can be used in script include helpers for external URLs.
static CspNonce(…) Gets a nonce value for use in script and style elements. Automatically generates and stores it in the current HTTP context items and adds it to the CSP directives.
static GetCspDirective(…) Gets a Content Security Policy directive added via AddCspDirective merged with any manual values provided. The string includes the final semicolon. This can be used to render parts of the CSP header or meta tag content.

See Also