[英]Getting ERR_CONNECTION_RESET from IIS with no information in logs
當我的ASP.NET服務器嘗試回復錯誤時,我在Chrome中獲得了ERR_CONNECTION_RESET
。
通常我可以通過查看日志文件找到有關服務器錯誤的信息,但那里什么都沒有。
在響應上運行調試器似乎表明一切正常,但最后,Chrome告訴我連接已重置。
以下是處理異常處理的代碼:
try
{
...
}
catch (ArgumentException e)
{
Response.StatusCode = 400;
Response.StatusDescription = e.Message;
return new ContentResult {Content = "" };
}
Chrome在控制台中顯示net::ERR_CONNECTION_RESET
。
使用Fiddler,我收到錯誤消息[Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.
[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)
我花了好幾個小時試圖調試這個沒有太多運氣。
在使用localhost上的一些虛擬域並分配SSL證書后,我遇到了這個問題。 選擇當前域的IIS開發證書時,錯誤消失。
事實證明這是由這條線引起的:
Response.StatusDescription = e.Message;
當e.Message里面有換行符( \\r\\n
)時。
我可用於修復此錯誤的兩個選項是:
1.將線替換為:
Response.StatusDescription = e.Message.Replace("\r\n"," ");
2.更換擋塊
catch (ArgumentException e)
{
Response.StatusCode = 400;
return new ContentResult {Content = e.Message };
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.