Response.Flush() throws System.Web.HttpException

后端 未结 4 990
迷失自我
迷失自我 2021-02-05 21:31

I have a HttpHandler that I\'m using to handle certain images on a client\'s website. When I\'m outputting the image stream to the response object and call Flush occasionally an

4条回答
  •  粉色の甜心
    2021-02-05 22:31

    For future readers..

    I ran into this case where Response.End() throws an error because the client is disconnected.

    An error occurred while communicating with the remote host. The error code is 0x80070057

    Oddly a CRLF in the StatusDescription was causing the connection to close.

    Response.StatusDescription = ex.Message;
    

    Cannot insert the value NULL into column '', table ''; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated

    Removing it fixed my problem.

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

提交回复
热议问题