ASP.NET load testing with Jmeter- Membership.GetUser() returns null in HttpHandler

浪尽此生 提交于 2019-12-12 04:39:02

问题


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


回答1:


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.




回答2:


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!



来源:https://stackoverflow.com/questions/8038369/asp-net-load-testing-with-jmeter-membership-getuser-returns-null-in-httphandl

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