Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# CSP内容安全策略Ajax调用被阻止_C#_Ajax_Asp.net Core_Http Headers - Fatal编程技术网

C# CSP内容安全策略Ajax调用被阻止

C# CSP内容安全策略Ajax调用被阻止,c#,ajax,asp.net-core,http-headers,C#,Ajax,Asp.net Core,Http Headers,我正在MVC core 2.2应用程序中使用NWebSec nuget包 如果我运行这段代码,我的Ajax调用将被阻止 任何想法 //CSP Content Security Policy app.UseCsp(options => options .DefaultSources(s => s.Self()) .ScriptSources(s => s.Self().UnsafeInlineSrc = true)

我正在MVC core 2.2应用程序中使用NWebSec nuget包 如果我运行这段代码,我的Ajax调用将被阻止 任何想法

 //CSP Content Security Policy
        app.UseCsp(options => options
            .DefaultSources(s => s.Self())
            .ScriptSources(s => s.Self().UnsafeInlineSrc = true) // allow inline script
            .ScriptSources(x=> x.Self().UnsafeEvalSrc = true) // allow events
            .ConnectSources(x=> x.Self().NoneSrc = true)
            .StyleSources(s=> s.Self().UnsafeInlineSrc = true));
我的Ajax调用是:

showPleaseWait();
    $.ajax({
        url: "@Url.Action("GetData", "DataGenerator")",
        dataType: 'json',
        type: "POST",
        data: { filter: selectedKeys },
        success:  function (d) {
            hidePleaseWait();
            window.location = "@Url.RouteUrl(new { Controller = "DataGenerator", Action = "downloadDocx"})/?fileName=" + d.filename;
        },
        error: function (xhr, status, error) {
            hidePleaseWait();
            alert("Error: Please refresh the page and try again!\n" + "Status:"+status + "\nError: " + error + "\nxhr.status: " + xhr.status + "\nxhr.statusText: " + xhr.statusText);
        }
    });
我的模式代码是:

  function showPleaseWait() {

    if (document.querySelector("#modalPush") == null) {
        var modalLoading = '<div class="modal" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false" role="dialog">\
        <div class="modal-dialog">\
            <div class="modal-content">\
                <div class="modal-header">\
                   <h4 class="modal-title">\
                     <span > Generating your report....</span> \
                    </h4>\
                </div>\
                <div class="modal-body">\
                    <div class="progress">\
                      <div class="progress-bar progress-bar-striped progress-bar-animated bg-success" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>\
                      </div>\
                    </div>\
         <div class="modal-footer">\
           <span > Please wait ....</span> \
            </div>\
                </div>\
            </div>\
        </div>\
    </div>';
        $(document.body).append(modalLoading);
    }

    $("#pleaseWaitDialog").modal("show");
}

function hidePleaseWait() {
    $("#pleaseWaitDialog").modal("hide");
}
函数showPleaseWait(){
if(document.querySelector(“#modalPush”)==null){
var modalLoading\
\
\
\
\
正在生成您的报告\
\
\
\
\
\
\
\
\
请稍等\
\
\
\
\
';
$(document.body).append(modalLoading);
}
$(“#请查看对话框”).modal(“显示”);
}
函数hideplasewait(){
$(“#请编辑对话框”).modal(“隐藏”);
}

您能否添加被阻止的呼叫以获得更多上下文信息?您是否可以向我们显示任何类型的错误消息?