.NetCore 代码检测工具之SecurityCodeScan

第一印象  简单、直观

感觉这个工具重点检测了CSRF风险

MVC中防止CSRF

参考:https://www.cnblogs.com/catcher1994/p/6720212.html

Controller中

Action注解组合拳 

[ValidateAntiForgeryToken] 单个Action

[AutoValidateAntiforgeryToken] 全局

[IgnoreAntiforgeryToken] 排除单个Action

View中

@Html.AntiForgeryToken()

AJAX提交

$("#btnAjax").on("click", function () {
    var token = $("input[name='__RequestVerificationToken']").val();
    $.ajax({
        type: "post",
        dataType: "string",
        url: '@Url.Action("AntiAjax", "Home")',
        data: "id="+$("#id").val(),
        headers:
        {
            "RequestVerificationToken": token
        },
        success: function (result) {
            alert(result);
        },
        error: function (err, scnd) {
            alert(err.statusText);
        }
    });
});
原文地址:https://www.cnblogs.com/jianghaidong/p/12658318.html