5

ERR_CONNECTION_RESET当我的 ASP.NET 服务器尝试回复错误时,我在 Chrome 中得到了一个。

通常我可以通过查看日志文件找到有关服务器错误的信息,但那里什么也没有。

在响应上运行调试器似乎表明一切正常,除了最后,Chrome 告诉我连接已重置。

这是处理异常处理的代码:

    try
    {
       ...
    }
    catch (ArgumentException e)
    {
        Response.StatusCode = 400;
        Response.StatusDescription = e.Message;
        return new ContentResult {Content = "" };
    }

Chromenet::ERR_CONNECTION_RESET在控制台中显示我。

使用 Fiddler,我收到错误消息[Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.

如果我在 IIS 中启用失败的请求跟踪,并打开生成的 xml 文件

    GENERAL_FLUSH_RESPONSE_END 


    BytesSent
    0 

    ErrorCode
    The parameter is incorrect.
     (0x80070057) 

我花了几个小时试图调试这个没有太多运气。

4

2 回答 2

16

在使用本地主机上的一些虚拟域并分配 SSL 证书后,我遇到了这个问题。为当前域选择 IIS 开发证书,错误消失了。

于 2018-02-13T12:26:30.697 回答
1

事实证明这是由这条线引起的:

 Response.StatusDescription = e.Message;

当 e.Message 内部有换行符 ( \r\n) 序列时。

我可用于修复此错误的两个选项是:

1.将行替换为:

 Response.StatusDescription = e.Message.Replace("\r\n"," ");

2.将catch块替换为

    catch (ArgumentException e)
    {
        Response.StatusCode = 400;
        return new ContentResult {Content = e.Message };
    }
于 2016-09-15T04:14:42.920 回答