Hello im struggling already a few days on this.
I have a aspx-Website and everything worked on my pc. Then after deploying it on a Server i get following errors:
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-ET0SWzTymVfQ+qjfGmR3CUWjxDefnjlCs53WMtvYTeU='), or a nonce ('nonce-...') is required to enable inline execution
My C#-Code have some onclick-methods and they transform to JavaScript and become a inline-function.
From:
<asp:CheckBox ID="CheckBox_MO_RS" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox_RIGHTS_CheckedChanged" Text="MO RS" />
To
<input id="CheckBox_MO_RS" type="checkbox" name="CheckBox_MO_RS" onclick="javascript:setTimeout('__doPostBack(\'CheckBox_MO_RS\',\'\')', 0)">
and those JS-Function doesnt work on the Server because of the violation of the CSP, i think.
What did i try?
- Tried to add CSP to Web.config.
- Didnt load at all on Server.
- Added meta tag to Header
- Sommething like this:
<meta http-equiv="Content-Security-Policy" content="script-src 'unsafe-inline'; script-src-elem 'unsafe-inline'"/>
- But then debuggers still returns the Error Message: Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'"
I didnt write the directive script-src 'self'. ErrorMessageDebugger Does anyone have any idea?