当我使用来自ASP.Net MVC 3.0的HttpStatusCodeResult返回带有换行符的StatusDescription时,强制关闭与我的客户端的连接.应用程序托管在IIS 7.0中.
示例控制器:
public class FooController : Controller
{
public ActionResult MyAction()
{
return new HttpStatusCodeResult((int)HttpStatusCode.BadRequest, "Foo \n Bar");
}
}
Run Code Online (Sandbox Code Playgroud)
示例客户端:
using (WebClient client = new WebClient())
{
client.DownloadString("http://localhost/app/Foo/MyAction");
}
Run Code Online (Sandbox Code Playgroud)
抛出异常:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
Run Code Online (Sandbox Code Playgroud)
使用curl时行为是一致的(curl 7.25.0(i386-pc-win32)libcurl/7.25.0 zlib/1.2.6) …