0

私は私のweb.configで以下を持っています:

<compilation defaultLanguage="vb" debug="false" targetFramework="4.0"/>
<customErrors mode="On" defaultRedirect="~/error.html"/>

標準エラー(存在しないページのクラッシュ/リクエストなど)に対して、カスタムエラーページを表示して正常に動作します。ただし、次の特定のリクエストでは失敗し、デバッグ情報が公開されます。

https://mywebsite/Page.aspx?error=<iframe>

これらを含むすべてのケースをキャプチャするにはどうすればよいですか?

返されるエラー ページは次のとおりです。

Server Error in '/' Application.

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>
4

1 に答える 1

3

ところで、IIS 7 を使用している場合

次のことを考慮してください。

1.) <httpErrors>:

<httpErrors>Web アプリケーションの外部で、IIS 自体にエラー ページを構成します。これにより、実際に ASP.NET または IIS によってネイティブに処理されるかどうかに関係なく、すべての要求が処理されます。

例えば。:

<httpErrors errorMode="Custom" existingResponse="Replace">
  <clear />
  <error statusCode="500" path="/Errors/500.aspx" responseMode="ExecuteURL"/>
  <error statusCode="404" path="/Errors/404.aspx" responseMode="ExecuteURL"/>
</httpErrors>

2.) HttpResponse.TrySkipIisCustomErrorsプロパティを使用して、IIS 7.0 カスタム エラーを無効にするかどうかを指定する値を取得または設定します。

TrySkipIisCustomErrors プロパティは、アプリケーションが IIS 7.0 でホストされている場合にのみ使用されます。IIS 7.0 でクラシック モードで実行している場合、TrySkipIisCustomErrors プロパティの既定値は true です。統合モードで実行している場合、TrySkipIisCustomErrors プロパティの既定値は false です。

于 2012-11-06T14:51:31.183 に答える