ASP.NET Ajax client-side framework failed to load.

MUHAMMAD AZEEM AZAM 1 Reputation point
2023-06-22T13:33:54.9133333+00:00

Hi,

.NETFramework = 4.5.2

I have a web page derived from master page. Master page contains Script Manager.

The Web page has 7 content place holders.

My CSP Policy (defined in WebConfig) is strict --> script-src 'self', but on chrome client side i get 4 directives.

  1. //<![CDATA[

var theForm = document.forms['aspnetForm'];

.....

  1. ASP.NET Ajax client-side framework failed to load.

there are 2 more

Looks to me the Scripts are not getting loaded. how to resolve the above errors (Directives)

Developer technologies ASP.NET Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. QiYou-MSFT 4,326 Reputation points Microsoft External Staff
    2023-06-23T07:27:10.3133333+00:00

    Hi @MUHAMMAD AZEEM AZAM

    ASP.NET WebForms has UI logic is closely related to the code and is difficult to separate from it, therefore scripts and styles are embedded in the generated HTML code uncontrollably.

    When using the WebForms, you can use '<hash-algorithm>-<base64-value>', but the hash values will depend on the deployment environment.

    For WebForms , ASP.NET itself inserts some inline scripts. To add the nonce= attribute to them and use 'nonce-<base64-value>', you need to override the built-in methods, for example CreateHtmlTextWriter

    I think this document is helpful to you: CSP in ASP.NET WebForms and ASP.NET MVC

    Best Regards

    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.