Eddie Fletcher
Eddie Fletcher

Reputation: 2873

Getting ERR_CONNECTION_RESET from IIS with no information in logs

I am getting a ERR_CONNECTION_RESET in Chrome when my ASP.NET server is trying to reply with an error.

Usually I can find information about server errors by looking in the log files, but there is nothing there.

Running a debugger over the reponse seems to show everything is OK, except at the end, Chrome tells me the connection was reset.

Here is the code that is handling the exception handling:

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

Chrome shows me net::ERR_CONNECTION_RESET in the console.

Using Fiddler, I get the error message [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.

If I Enable Failed Request Tracing in IIS, and open the generated xml file

    GENERAL_FLUSH_RESPONSE_END 


    BytesSent
    0 

    ErrorCode
    The parameter is incorrect.
     (0x80070057) 

I have spent hours trying to debug this without much luck.

Upvotes: 5

Views: 21657

Answers (2)

Stefan Michev
Stefan Michev

Reputation: 5093

I had this issue after playing around with some virtual domains on the localhost and assigning SSL Certificates. Selecting the IIS Development Certificate for the current domain the error disappeared.

Upvotes: 18

Eddie Fletcher
Eddie Fletcher

Reputation: 2873

It turns out this was caused by this line:

 Response.StatusDescription = e.Message;

When e.Message has a newline (\r\n) sequence inside.

The two options I had available to fix this error were:

1. Replace the line with:

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

2. Replace the catch block with

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

Upvotes: 1

Related Questions