问题
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