The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NonceTagHelper.cs 588B

12345678910111213141516171819
  1. using Microsoft.AspNetCore.Mvc.Rendering;
  2. using Microsoft.AspNetCore.Mvc.ViewFeatures;
  3. using Microsoft.AspNetCore.Razor.TagHelpers;
  4. namespace Teknik.Utilities.TagHelpers
  5. {
  6. [HtmlTargetElement("script")]
  7. public class NonceTagHelper : TagHelper
  8. {
  9. [HtmlAttributeNotBound]
  10. [ViewContext]
  11. public ViewContext ViewContext { get; set; }
  12. public override void Process(TagHelperContext context, TagHelperOutput output)
  13. {
  14. output.Attributes.SetAttribute("nonce", ViewContext.HttpContext.Items[Constants.NONCE_KEY]);
  15. }
  16. }
  17. }