_RequestTokenVerification不存在 [英] _RequestTokenVerification not present

查看:89
本文介绍了_RequestTokenVerification不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我正在解决Antiforgery的问题__RequestTokenVerification不存在。



不是在页面或应用程序中获取此异常。



但是使用zap工具并运行它我可以在事件查看器中看到异常。



我在我的控制器中使用了[HttpZPost],[ValidateAntiForgeryToken]属性,并在所有视图窗体中使用@ Html.AntiforgeryToken()。



使用jQuery和ajax调用将数据发送到服务器

 $。fn.executeCommand =  function (命令,操作){
$( this )。each( function (){
$( this )。click( function (){
action = action || $( this )。data( )|| $( this )。attr(' href');
var form = $( < form method ='post'action =' + action + '>< input type = 'hidden'name ='CommandName'value =' + command + '>< / form>)。appendTo($( body));

$(' < input />')。attr( ' type'' hidden'
.attr(' name' __ RequestVerificationToken
.attr(' value',$(' #__ AjaxAntiForgeryForm输入[name = __ RequestVerificationToken]')。val())
.appendTo(form);

form.submit();
return false ;
});
});
};



请帮忙解决一下。

问候

sarfaraz

解决方案

.fn.executeCommand = function (命令,操作){


this )。each( function (){


this )。click( function (){
action = action ||

Hello,

I am going through problem with Antiforgery __RequestTokenVerification not Present.

Am not getting this exception on the page or in application.

But using zap tool and run it i can see the exception in the event viewer.

I have use the attribute [HttpZPost], [ValidateAntiForgeryToken] in my controller and use the @Html.AntiforgeryToken() in all the view forms.

using jQuery and ajax call send data to server

$.fn.executeCommand = function(command, action) {
    $(this).each(function() {
        $(this).click(function() {
            action = action || $(this).data("action") || $(this).attr('href');
            var form = $("<form method='post' action='" + action + "'><input type='hidden' name='CommandName' value='" + command + "'></form>").appendTo($("body"));

            $('<input />').attr('type', 'hidden')
                .attr('name', "__RequestVerificationToken")
                .attr('value', $('#__AjaxAntiForgeryForm input[name=__RequestVerificationToken]').val())
                .appendTo(form);

            form.submit();
            return false;
        });
    });
};


Please help out how to resolve it.
Regards
sarfaraz

解决方案

.fn.executeCommand = function(command, action) {


(this).each(function() {


(this).click(function() { action = action ||


这篇关于_RequestTokenVerification不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆