Skip to content

Instantly share code, notes, and snippets.

@emrekizildas
Created October 5, 2019 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emrekizildas/d61def377de36b47414ce397c7fa48d9 to your computer and use it in GitHub Desktop.
Save emrekizildas/d61def377de36b47414ce397c7fa48d9 to your computer and use it in GitHub Desktop.
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace CSPExample.Helper
{
public static class NonceHelper
{
public static HtmlString Nonce(this IHtmlHelper helper)
{
string nonceValue = helper.ViewContext.HttpContext.Items["ScriptNonce"].ToString();
return new HtmlString(nonceValue);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment