通过 节,可以配置,在执行请求的过程中出现未处理的错误时要执行的操作。具体而言,
开发人员通过该节可配置要显示的 html 错误页,以代替错误堆栈跟踪。
在web.config文件的configuration节点下面添加如下代码:
<customErrors mode="RemoteOnly" defaultRedirect="/Pages/Error/Error.aspx">
<error statusCode="403" redirect="/Pages/Error/Error.aspx"/>
<error statusCode="404" redirect="/Pages/Error/FileNotFound.aspx"/>
<error statusCode="401" redirect="/Pages/Error/Error.aspx"/>
<error statusCode="500" redirect="/Pages/Error/Error.aspx"/>
</customErrors>
具体页面路径自行更改。