使用 Jmeter-Membership.GetUser() 进行 ASP.NET 负载测试在 HttpHandler 中返回 null
我之前曾使用 Jmeter 通过表单身份验证对我的 ASP.NET 4 站点进行负载测试,并且一切正常。
从那时起,添加了几个 HttpHandler,这就是我正在尝试加载测试的内容。如果使用 1 个线程对其进行负载测试,则一切正常。如果我使用 2 个线程加载测试,则在调用 Membership.GetUser()
时会抛出空引用异常。我已在本地对此进行了调试,并且可以看到 HttpContext.Current.User
也为 null,但是调用 Membership.GetUser("userName")
返回用户。
我知道该应用程序可以处理 2 个以上的用户,我刚刚使用了另一个负载测试应用程序(Web Performance Load Tester)并且它没有出错。
有人能指出我正确的方向吗?
谢谢
编辑:
只是为了澄清一下,我在经过身份验证后对此进行了测试
I've used Jmeter before to load test my ASP.NET 4 site with Forms Authentication and all worked fine.
Since then several HttpHandlers have been added, which is what I'm trying to load test. If a load test it with 1 thread everything works fine. If i load test with 2 threads, i get a null reference exception thrown when calling Membership.GetUser()
. I've debugged this locally and can see that HttpContext.Current.User
is null as well, however calling Membership.GetUser("userName")
returns the user.
I know that the application can handle more than 2 users, I've just used another load testing application (Web Performance Load Tester) and it didn't error.
Can anyone point me in the right direction please?
Thanks
edit:
Just to clarify, I am testing this after I've authenticated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是身份验证主体不会被设置,直到
下一个请求到服务器。
如果您使用的是登录控件,则可以使用 UserName 属性来
识别用户。问题背后的主键。
The problem is that the authentication principal won't get set until the
next request to the server.
If you are using the Login control, you can use the UserName property to
identify the user.Main key behind your problem.
我的问题是由于 Jmeter 中的“用户参数预处理器”元素没有正确/足够快地执行。我已将其替换为“CSV 数据集配置”元素,并将其直接添加到线程组下方,并且工作正常。
由于未使用用户参数,因此线程未登录到 Web 应用程序,因此
GetUser()
返回 null!My problem was due to the "User Parameters Pre Processor" element in Jmeter not being executed properly/soon enough. I have replaced this with a "CSV Data Set Config" element and added it directly underneath the thread group and it works fine.
As the user parameters weren't being used the thread were not being logged in to the web application, hence why
GetUser()
was returning null!