ASP.NET load testing with Jmeter- Membership.GetUs

2019-09-06 05:36发布

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

2条回答
手持菜刀,她持情操
2楼-- · 2019-09-06 06:08

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.

查看更多
唯我独甜
3楼-- · 2019-09-06 06:14

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!

查看更多
登录 后发表回答