问题
I'm in the process of developing some load tests for an internal web application.
The problem appears 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?
回答1:
Select The Test Main node, and click the red marked button to set credentials
回答2:
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.
回答3:
I found this works...
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
来源:https://stackoverflow.com/questions/4190758/how-to-load-test-a-web-page-using-windows-authentication