jmeter中记录的脚本给出了401 Unauthorized错误

时间:2016-02-17 11:56:22

标签: jmeter performance-testing load-testing

我正在尝试加载测试我的应用程序。但是当我尝试通过jmeter运行录制的脚本时,我只在少数特定页面上获得401 Unauthorized错误。该脚本在“登录”页面运行,但在其他页面上出错。我需要使用多个用户运行整个场景(CSV文件) 这是请求标签:

POST数据: { “searchObject”:{ “名字”: “”, “姓”: “”, “角色ID”: “”, “StatusId”: “”, “中将sortOrder”: “ID”, “isAsc”: “假”, “isInactivated”:假 “tempDataFlag”: “正确”}, “isSorting”: “假”, “LISTNAME”: “CreissStaffList”}

Cookie Data:
ASP.NET_SessionId=0zqlv4t4ayszinlteqgnlrvg; __RequestVerificationToken=mmFzWMMfWojIH9J-32ylhW_8oseKWMP84XRZALQmUh0VfGmflM_kVW3b1MmWYLJ5ySCIezacyBFYplhzTSWMeo7CnMh2j14sD10qX2S_fq41

Request Headers:
Connection: keep-alive
Referer: https://www.creissmed.de/Admin/UserList
Accept-Language: en-US,en;q=0.5
X-Requested-With: XMLHttpRequest
Content-Type: application/json; charset=utf-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
Accept: application/json, text/javascript, */*; q=0.01
Content-Length: 199

采样器结果:

Thread Name: Thread Group 1-1
Sample Start: 2016-02-17 17:17:05 IST
Load time: 142
Connect Time: 0
Latency: 142
Size in bytes: 1599
Headers size in bytes: 255
Body size in bytes: 1344
Sample Count: 1
Error Count: 1
Response code: 401
Response message: Unauthorized

Response headers:
HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Type: text/html
Location: /
Server: Microsoft-IIS/8.5
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 17 Feb 2016 11:47:03 GMT
Content-Length: 1344


HTTPSampleResult fields:
ContentType: text/html
DataEncoding: iso-8859-1

这就是HTTP请求页面的样子: 路径:/ Admin / GetListData 身体参数:

{"searchObject":{"LastName":"","FirstName":"","RoleId":"","StatusId":"","sortOrder":"Id","isAsc":"False","isInactivated":false,"tempDataFlag":"True"},"isSorting":"false","listName":"CreissStaffList"}

我只在GetListData HTTP请求页面上获取错误 提前谢谢!

1 个答案:

答案 0 :(得分:1)

  1. 添加View Results Tree侦听器并检查响应详细信息。如果您没有看到错误消息,那么它并不一定意味着登录成功,尽管HTTP响应代码200该页面可能包含错误。
  2. 您可能需要对__RequestVerificationToken进行一些处理,因为在进行反跨站点伪造实施时,您需要进行一些关联才能绕过它。有关详细说明和可能的选项,请参阅How to Load Test CSRF-Protected Web Sites指南。