asp.net - Visual Studio 2013 WebTest 请求失败 : An existing connection was forcibly closed by the remote host

标签 asp.net iis visual-studio-2013 load-testing

我正在尝试在我的本地计算机上运行 Visual Studio 2013 网络测试。这是我成功运行的测试(上一次大约 2 个月前)。 Web 测试的第一步是向登录页面发出 GET 请求。它看起来像这样:

获取 https://example.com/Login.aspx

当我在网络浏览器中输入此 URL 时,它成功了。此外,我可以成功地记录一个网络测试,我只需导航到此页面并登录。但是当我尝试重新运行我刚刚记录的网络测试时,我得到了对 GET 请求的响应:

Request failed: An existing connection was forcibly closed by the remote host

IIS 没有在 example.com 上记录任何内容(IIS 不记录 GET 请求)。但是,当我手动登录或记录 Web 测试时,IIS 会正确记录 GET 请求。

example.com 或我的本地主机上的事件查看器中没有记录任何消息。

非常感谢有关如何调试此问题的任何建议。

最佳答案

对我来说,问题是 TLS 握手。通过在 web 测试中添加插件解决。

认为是原始问题,对我有帮助:https://social.msdn.microsoft.com/Forums/vstudio/en-US/bc3ebf23-575d-4e54-bd6b-a1ed87fe5213/web-performance-test-is-not-working-with-tls12-enabled?forum=vstest

插件来源:

using System;
using System.ComponentModel;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using Microsoft.VisualStudio.TestTools.WebTesting;

[Description("This plugin will force the underlying System.Net ServicePointManager to negotiate downlevel SSLv3 instead of TLS. WARNING: The servers X509 Certificate will be ignored as part of this process, so verify that you are testing the correct system.")]
public class TLSPlugin : WebTestPlugin
{
    [Description("Enable or Disable the plugin functionality")]
    [DefaultValue(true)]
    public bool Enabled { get; set; }
    public override void PreWebTest(object sender, PreWebTestEventArgs e)
    {
        base.PreWebTest(sender, e);

        //For TLS
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

        //For SSL
        //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
        //we wire up the callback so we can override  behavior and force it to accept the cert
        ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCB;

        //let them know we made changes to the service point manager
        e.WebTest.AddCommentToResult(this.ToString() + " has made the following modification-> ServicePointManager.SecurityProtocol set to use SSLv3 in WebTest Plugin.");
    }
    public static bool RemoteCertificateValidationCB(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
    {
        //If it is really important, validate the certificate issuer here.
        //this will accept any certificate
        return true;
    }
}

关于asp.net - Visual Studio 2013 WebTest 请求失败 : An existing connection was forcibly closed by the remote host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40870624/

相关文章:

c# - 如何在 TableClient.QueryAsync() 中筛选分页查询结果 [Azure.Data.Tables]

asp.net - ASP.NET 应用程序的物理内存太多?

iis - Wix & Burn - 如果尚未安装,请安装 IIS

c++ - 将项目从 **VS 2012** 迁移到 **VS2013** 后 Dll Register 问题

asp.net - 设置值时页面移位-我的代码或最新版本的chrome中存在错误?

c# - 如何使用 dom-construct 插入带有查询字符串的 iframe 并在 Controller 中读取请求?

asp.net - 在 Azure 应用程序网关卸载时如何需要 SSL?

iis - 发生错误时IIS7中出现500.19错误

asp.net - 在 Visual Studio 中调试时无法识别属性 ‘targetframework’

visual-studio - SSDT 模式比较 - 忽略系统服务代理(VS 2013)