Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
506 views
in Technique[技术] by (71.8m points)

asp.net mvc - Correlation issue in jmeter:The required anti-forgery form field "__RequestVerificationToken" is not present

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. enter image description here

Here in the result tree, the request send with token enter image description here

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

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) 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...