アプリケーションから404エラーが発生します。
404エラーのページは/ErrorPages/Error_404.cshtml
です。このファイルにはHTMLコードしかありません。正常に動作します。
しかし、私はいくつかのかみそりのコードを追加すると、ブラウザに設定エラーがスローされます。
私は例えばレイアウトまたは一部@Html.ActionLink(...
これは誤りであるを追加します。cshtml(エラー)ページのカミソリコード
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.
Details: To enable the details of this specific error message to be viewable on the local server machine, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "RemoteOnly". To enable the details to be viewable on remote machines, please set "mode" to "Off".
これは私が404を生成する方法である:
public ActionResult Search(string searchTerm)
{
if (city == null)
{
throw new HttpException(404, "Some description");
}
else
{
return RedirectToAction("Index", "Home", new
{...
}
}
とNOかみそりコードは、それがエラーページではありませんうまくいけば、私は上からメッセージを受け取ります。
私は、Web設定「モード=オフ」に設定すると、私はエラーメッセージが表示されます。これは、Web構成
<customErrors mode="Off">
<error statusCode="404" redirect="\ErrorPages\Error_cp404.cshtml" />
</customErrors>
は、web.configファイルでオフにカスタムエラーを設定し、私達に実際のエラーメッセージを伝える:
また、あなたがIIS7 +で実行している場合は、次を追加する必要があるかもしれません。 – Judo
@Judoカスタムエラーをオフにすると、システムはエラーメッセージページを表示せず、デフォルトの例外スタックを表示します。 1110、あなたはそのページをデバッグし、実際のエラーを表示してください – archil
あなたのコメントに基づいて私の質問が更新されました。 – 1110