Found this, when I had a a CSP-related error. Thx for the post, this lead me a shorter "implementation". I assume, when you posted your solution, the ejs-scripts tag did not have a "add-nonce" attribute, thats why you overriden the TagHelper.
Now it works without it, and with just
Simply DI ICspNoneService into the (partial) view where you have the ejs-scripts tag and with 3 lines of simplest code (and no overriding) the issue is solved.
@using Syncfusion.EJ2
/// dependency to be able to inject the ICspNonceService @using Joonasw.AspNetCore.SecurityHeaders.Csp
/// inject the service @inject ICspNonceService NonceService
/// change the ejs-script tag
<ejs-scripts add-nonce="@NonceService.GetNonce()"></ejs-scripts>
Hi Reto,
We let you know that we have provided nonce support for ASP.NET core components and can add the “add-nonce” property to the script without using any external TagHelpers. We have prepared a sample for your reference which you can download from the below link.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CORENO~12007670104
Code Snippets:
|
~/Views/Shared/_Layout.cshtml
<head> ..... <link rel="stylesheet" rel='nofollow' href=https://cdn.syncfusion.com/ej2/20.1.48/bootstrap5.css />
<script src=https://cdn.syncfusion.com/ej2/20.1.48/dist/ej2.min.js nonce="@Context.Items["ScriptNonce"]"></script>
</head> <body> .....
<ejs-scripts add-nonce="@Context.Items["ScriptNonce"]"></ejs-scripts>
</body> |
Kindly try with the sample and get back to us if you have any queries.
Regards,
Joshna L