VISH,Inc.

.NET FrameworkのHttpWebRequestはHTTPの100 Continueの処理が不完全

とのことです。

具体的には、POSTの際やプロキシ接続の際に、

System.Net.WebException: 基礎になる接続が閉じられました: 接続が予期せずに閉じられました

という例外が発生している場合は、100 Continue処理の不具合を疑った方がよさそうです。

以下のコードにて回避可能とのこと。

ServicePoint currentServicePoint = request.ServicePoint;
if (currentServicePoint == null)
{
    currentServicePoint = ServicePointManager.FindServicePoint(new Uri(url));
}
if (currentServicePoint.Expect100Continue == true)
{
    currentServicePoint.Expect100Continue = false;
}

いわゆるバッドノウハウなんですが、とりあえずメモしておきます。

blog.vish.co.jp

Leave a Reply


VISH企業サイト
サイトマスター.jp
モバイルサイト制作・構築