代码:

//配置所有POST请求都加入 ValidateAntiforgeryToken 验证
            services.AddAntiforgery(options =>
            {
                options.FormFieldName = "AntiforgeryFieldName";
                options.HeaderName = "X-CSRF-TOKEN-HEADERNAME";
                options.SuppressXFrameOptionsHeader = false;
            });
            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

 

posted on 2020-10-20 17:00  邢帅杰  阅读(215)  评论(0编辑  收藏  举报