zoukankan      html  css  js  c++  java
  • .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);
            }
        });
    });
  • 相关阅读:
    第四次作业
    第三次
    第十次作业
    第九次作业
    第八次作业
    10.29第七次
    15
    14
    13 this
    12 电视机
  • 原文地址:https://www.cnblogs.com/jianghaidong/p/12658318.html
Copyright © 2011-2022 走看看