How to load test a web page using Windows authentication
I'm in the process of developing some load tests for an internal web application.
The problem 开发者_如何学Cappears to be related to our use of Windows authentication. I can access the web application if I launch the browser and nevigate to our app. I can't, however, access the application via webrequest in my load test. It throws a 401 exception, Unauthorized.
I'm using Visual Studio 2010 Ultimate.
How do I use my Windows credentials in my load test? Any other ideas?
Select The Test Main node, and click the red marked button to set credentials
If your load testing tool doesn't have a way to specify the credentials to run under, you will have to use Windows Impersonation (just to perform your tests).
You could potentially do this in code (see here: http://www.codeproject.com/KB/cs/cpimpersonation1.aspx), but if you don't need to get fancy, it will be easier to update your web.config with the credentials to run under:
<identity impersonate="true" userName="accountname" password="password" />
This should work for any pages under the web site for which the web.config is configured.
I found this works...
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
精彩评论