在web.config文件中,可以通過(guò)以下方式配置customerrors:
<system.web>
<customErrors mode="On" />
</system.web>
<system.web>
<customErrors mode="On" defaultRedirect="ErrorPage.aspx" />
</system.web>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="NotFound.aspx" />
<error statusCode="500" redirect="ServerError.aspx" />
</customErrors>
</system.web>
以上是常見(jiàn)的配置方式,可以根據(jù)需求進(jìn)行調(diào)整。