C# ';不安全评估';MVC样板

C# ';不安全评估';MVC样板,c#,ajax,asp.net-mvc,model-view-controller,content-security-policy,C#,Ajax,Asp.net Mvc,Model View Controller,Content Security Policy,我得到了一个错误: vendor.js:328 Uncaught EvalError:拒绝将字符串作为JavaScript求值,因为在以下内容安全策略指令中,“script src'self'localhost:*ajax.googleapis.com ajax.aspnetcdn.com”不是脚本的允许源 我知道通过设置UnsafeEval=true, 但这是不安全的,并且会使我的站点暴露XSS漏洞 因此,当我使用AJAX时,有没有一种方法可以允许使用一些脚本和表单。也许你们可以给我举个例子,

我得到了一个错误:

vendor.js:328 Uncaught EvalError:拒绝将字符串作为JavaScript求值,因为在以下内容安全策略指令中,“script src'self'localhost:*ajax.googleapis.com ajax.aspnetcdn.com”不是脚本的允许源

我知道通过设置
UnsafeEval=true,
但这是不安全的,并且会使我的站点暴露XSS漏洞

因此,当我使用AJAX时,有没有一种方法可以允许使用一些脚本和表单。也许你们可以给我举个例子,告诉我如何使用这些方法,我不太确定怎么做

new CspFormActionAttribute()
{
    // Allow forms to post back to example.com.
    // CustomSources = "*.example.com",
    // Allow forms to post back to the same domain.
    Self = true
});

new CspChildSrcAttribute()
{
    // Allow web workers or embed frames from example.com.
    // CustomSources = "*.example.com",
    // Allow web workers or embed frames from the same domain.
    Self = false
});

// connect-src - This directive restricts which URIs the protected resource can load using script interfaces
// (Ajax Calls and Web Sockets).
filters.Add(
    new CspConnectSrcAttribute()
    {

        // Allow Browser Link to work in debug mode only.
        CustomSources = string.Join(" ", "localhost:*", "ws://localhost:*"),

        // Allow AJAX and Web Sockets to example.com.
        // CustomSources = "*.example.com",

        // Allow all AJAX and Web Sockets calls from the same domain.
        Self = true
    });

你的Javascript在哪里?你的Javascript在哪里?