0

今日から、ASP.NET MVC を使用する IIS7.5 で例外が発生しましたが、その理由がわかりません。

System.Net.WebClient.DownloadString() の使用中に発生します

[WebException: リモート サーバーがエラーを返しました: (500) Internal Server Error.]

ブラウザでURLを開いた場合。サイトは正常に表示されます。

VS2008 のデバッグ トレース ステータスは「200 OK」です。

それが見ることができた唯一のものは:

Type Exception "System.PlatformNotSupportedException" の Response.Headers" が発生しました。 System.Collections.Specialized.NameValueCollection {System.PlatformNotSupportedException}

IIS の統合パイプライン モードを使用してください。

どちらの Web サイトも、統合パイプラインが有効になっている同じ v2.0 .NET アプリケーション プール内で実行されます。google.com などからの DownloadString は機能します。MVC を呼び出した場合にのみ、破損します。

MVC で呼び出されたコントローラーは次のようになります。

    public void online()
    {
        Response.Write(Date.Time.Now);
        Response.End();
        return;
    }

以前は機能していました。誰かがエラーを追跡するために詳細を取得するのを手伝ってくれるかもしれません.

アップデート:

とった。くそ。ASP.NET MVC で Subversion History をチェックし、すべての行をチェックしました。私の BaseController では、最近追加しました:

string strUserAgent = Request.UserAgent.ToString().ToLower();

取り外し後。すべてが再び機能します。しかし、UserAgent を要求すると System.Net.WebClient がクラッシュするのはなぜですか? 200ステータスでも。これは少し調べてみます。

4

1 に答える 1

0

In my case this does the trick:

if (Request.UserAgent != null)
{
  string strUserAgent = Request.UserAgent.ToString().ToLower();
}

but its quite stuipid of System.Net.WebClient to throw an Exception when Webserver is doing Request.UserAgent even there is HTTP Status 200.

于 2010-01-14T15:54:13.700 に答える