2012-03-06 8 views
0

サーバーにプロジェクトをデプロイすると、特定の状況でカスタムエラーページを作成する必要があることを示すエラーページが表示されます。私は、正確に私はこのカスタムエラーページを実装するだろうと思っていたサーバーが私に正確かつ有用なメッセージを与えるか、好ましくは、どのように私はメインページに表示するだけのエラーを取得するか?エラーの詳細ではなくエラー特定のページをサーバーに要求します

これは、私は、ページが明記としてあなたは、<customErrors mode="Off"/>を設定することで、実際のエラーを表示することができます

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 remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off". 


<!-- Web.Config Configuration File --> 

<configuration> 
    <system.web> 
     <customErrors mode="Off"/> 
    </system.web> 
</configuration> 

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL. 


<!-- Web.Config Configuration File --> 

<configuration> 
    <system.web> 
     <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> 
    </system.web> 
</configuration> 

答えて

1

下になったエラーメッセージです。

しかし、それは良い考えではありません。エラーメッセージには機密情報が含まれている可能性があり、攻撃者がサイトの実際のセキュリティホールを見つけるのに役立ちます。 (これは、ASP.Netにデフォルトでエラーが表示されない理由です)

代わりに、すべてのエラーを記録して報告する必要があります。ELMAH

0

これに対応して、2つのうちの1つを実行できます。

いずれの場合も、web.configの応答に最初のスニペットを追加すると、すべてのエラー情報を表示できます。 (私はこれをお勧めしません)

<configuration> 
    <system.web> 
     <customErrors mode="Off"/> 
    </system.web> 
</configuration> 

それとも、あなたが好きな任意のページを作成します。あなたのウェブサイトに "mycustompage.htm"という名前のページを追加するなど。

<configuration> 
    <system.web> 
     <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> 
    </system.web> 
</configuration> 
:あなたのweb.configファイルに以下を追加することにより、

<b>An Error has occured, please try again later.</b> 

:そして、単にような何かを持ちます

関連する問題