将 nonce 属性添加到自动生成的 WebForms 脚本 [英] Add nonce attribute to auto-generated WebForms script

查看:49
本文介绍了将 nonce 属性添加到自动生成的 WebForms 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上实现 CSP 标头时,我遇到了 webforms 添加到页面的自动生成的回发 JavaScript 的问题:

While implementing the CSP header on my website, I am facing problems with the automatically generated postback JavaScript that webforms adds to the page:

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>

为了支持其他一些内联脚本标签,我已经成功添加了 nonce 属性;但是我找不到修改这段生成的代码来做同样的事情的方法.我已经探索了 ClientScript.GetPostBackEventReference,但这似乎控制了其中的 JavaScript,与

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆