Visual Studio Web性能测试 - 错误407 Web身份验证

Visual Studio Web性能测试 - 错误407 Web身份验证

问题描述:

首先,我只是想感谢您以前对以前的查询提供的所有支持(以及我从未对所有评论做出回应的道歉)..

First I just wanted to say thanks for all your previous support on previous queries (and apologies I never did get to respond to all comments)..

我有另一个查询可能与我在这里看到的其他人有关,但遗憾的是无法解决我的问题。  我正在测试一个外部测试网站,该网站位于他们自己的本地域中,但是我要求提供Windows安全管理员的用户名和密码,

I have another query which might relate to others I've seen here, but unfortunately do not help resolve my issue.  I'm testing an external test website, held within their own local domain, but which requests a Windows Security username and password, which I have.

申请Web性能测试时,我收到了许多未经授权的407条消息。  我已经使用了Set Credentials选项查看是否可以解决任何问题,但是虽然我可以进一步解决,但在重新运行WebTest时仍然会收到407(未授权),
400和403(禁止)错误。

When applying to the Web Performance Test, I've been getting a number of 407 unauthorised messages.  I've used the Set Credentials option to see if that resolves anything, but although I can get a little further, I still receive 407 (unauthorised), 400, and 403 (forbidden) errors upon rerunning the WebTest.

非常感谢任何帮助。

非常感谢

上一页

P Sooben

嗨Sooben,

Hi Sooben,

欢迎来到MSDN论坛。

Welcome to MSDN Forum.

据我所知,错误407意味着需要代理身份验证。客户端必须在代理服务器上进行身份验证,代理服务器必须返回Proxy-Authenticate以对查询进行身份验证,客户端可以返回Proxy-Authorization头以进行身份​​验证。

As far as I know, Error 407 means proxy authentication required. The client must authenticate on the proxy server, proxy server must return a Proxy-Authenticate to authenticate queries, the client can return a Proxy-Authorization headers for authentication.

因此,请先检查代理,然后创建一个Web测试插件,将当前登录用户的凭据提供给代理。

Therefore, please first check the Proxy, and then create a web test plug-in supply the credentials of the currently logged on user to the proxy.

此链接说明如何为Web性能测试指定代理服务器:

This link explain how to specify a proxy server for a web performance test:

https://msdn.microsoft.com/en-us/library/ff400220(v=vs.110).aspx

这是插件示例代码:

•	public class MyWebTestPlugin : WebTestPlugin   
•	9     {   
•	10   
•	11   
•	12         public override void PreWebTest(object sender, PreWebTestEventArgs e)   
•	13         {   
•	14             // Create a WebProxy object for your proxy   
•	15             WebProxy webProxy = new WebProxy("<http://yourproxy>");   
•	16   
•	17             //Set the WebProxy so that even local addresses use the proxy   
•	18             // webProxy.BypassProxyOnLocal = false;   
•	19   
•	20             // Use this WebProxy for the Web test   
•	21             e.WebTest.WebProxy = webProxy;   
•	22   
•	23   
•	24   
•	25             e.WebTest.PreAuthenticate = true;   
•	26             NetworkCredential proxyCredentials;   
•	27   
•	28             proxyCredentials = new NetworkCredential();   
•	29   
•	30             proxyCredentials.Domain = "yourDomain";   
•	31             proxyCredentials.UserName = "yourUserName";   
•	32             proxyCredentials.Password = "yourPassword";   
•	33             e.WebTest.WebProxy.Credentials = proxyCredentials;   
•	34   
•	35   
•	36   
•	37   
•	38         } 

参考链接:

https://blogs.msdn.microsoft.com/tfssetup/2016/05/31/how-to-add-a- web-performance-test-plug-in-to-authenticate-through-different-proxy-in-visual-studio-2015 /

希望它有所帮助。

祝你好运,

Fletch