Correlation issue in jmeter:The required anti-forgery form field “__RequestVerificationToken” is not present

China☆狼群 提交于 2020-01-06 08:09:05

问题


Am trying to generate performance test script in jmeter.

Here one of the page requires __RequestVerificationToken as one field which need to be generated from previous page. We have used regular expression extractor to capture the token and passed the same in subsequent request. In the view result tree, I can see the request verification token in appropriate but we are getting an error

The required anti-forgery form field "__RequestVerificationToken" is not present.

Here is the regular expression extractor we used.

Here in the result tree, the request send with token

Here is the request id which passed through cookie. which will different from previous request. this system genearted.

Please help us, we stuck in this for last two weeks

Following error is thrown in our application,

System.Web.Mvc.HttpAntiForgeryException (0x80004005): The required anti-forgery form field "__RequestVerificationToken" is not present.
     at abc.def.Web.Filters.ApplicationHandleErrorAttribute.OnException(ExceptionContext filterContext)
     at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)
     at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState)
     at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
     at System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state)     at System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState)
     at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
     at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
     at System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state)     at abc.def.Web.Base.BaseController.BeginExecuteCore(AsyncCallback callback, Object state)
     at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
     at System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)
     at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState)
     at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
     at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
     at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

回答1:


Looking into the pictures it appears that somewhere somehow your extraction fails or you're using hard-coded value instead of extracted one. I would recommend double checking the extracted value using Debug Sampler and View Results Tree listener combination and ensuring you're using ${RequestVerificationToken} in the HTTP Request.


Also if the variable comes as a HTTP Cookie you can get it directly from the HTTP Cookie Manager like:

  1. Add the next line to user.properties file (lives in "bin" folder of your JMeter installation)

    CookieManager.save.cookies=true
    
  2. Restart JMeter to pick up the change
  3. Refer the cookie value as ${COOKIE____RequestVerificationToken} where required.

More information: HTTP Cookie Manager Advanced Usage - A Guide



来源:https://stackoverflow.com/questions/47854117/correlation-issue-in-jmeterthe-required-anti-forgery-form-field-requestverif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!