jMeter 登录问题与 MVC 和 Anti Forgery
Posted
技术标签:
【中文标题】jMeter 登录问题与 MVC 和 Anti Forgery【英文标题】:jMeter Login issue with MVC and Anti Forgery 【发布时间】:2016-02-08 13:33:30 【问题描述】:我正在尝试使用 jMeter 对我的网站进行负载测试。 我的登录页面出现问题。我已经通过 RegEx 捕获它在登录页面中传递了 __RequestVerificationToken 值,如下所示:
Field to check: Body.
Reference Name: token.
Regular Expression: <input name="__RequestVerificationToken" type="hidden" value="(.*)" />.
Template: $1$
我仍然收到与响应相同的错误:
<title>The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the <machineKey> configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.</title>
<b> Exception Details: </b>System.Web.Mvc.HttpAntiForgeryException: The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the <machineKey> configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.<br><br>
查看树结果中“请求”选项卡的更多详细信息:
POST data:
__RequestVerificationToken=%24%7Btoken%7D&UserModel.UserName=pm&UserModel.Password=Abc1234D
Cookie Data:
ASP.NET_SessionId=l0cvy41ons0xv1t3e5glx2j5; __RequestVerificationToken_L0NyZWlzc1dlYg2=elGNi5_GoW2DYFM-obeXg9DHsihM26jv8HgT4IEpjngwc1gfJ4lRTboi3t-UV4L9485dM_9bdAVfRZKauTIXAZoKvNt2Q9R0yW19ZQIO17A1
Request Headers:
Connection: keep-alive
Referer: http://172.52.50.137/CreissWeb/
Accept-Language: en-US,en;q=0.5
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Length: 91
Host: 172.52.50.137
HTTP 请求:
__RequestVerificationToken $token false true
UserModel.UserName pm false true
UserModel.Password Abc1234D false true
任何帮助将不胜感激。 !!
【问题讨论】:
您确定 __RequestVerificationToken 值按您的预期被 RegEx 捕获吗?您需要提供更多详细信息。 谢谢,@VinothS。我已经用更多细节更新了这个问题,请看一下。希望有帮助! 【参考方案1】:您的正则表达式提取器未按预期工作。 POST 数据清楚地显示__RequestVerificationToken=$token
。
尝试将正则表达式更改为name="__RequestVerificationToken" type="hidden" value="(.*)"
看看是否有帮助。
如果它不起作用,发布你得到的 HTTP 响应。
【讨论】:
以上是关于jMeter 登录问题与 MVC 和 Anti Forgery的主要内容,如果未能解决你的问题,请参考以下文章