c# 执行请求的过程中出现错误时配置报错页面代替错误堆栈跟踪

来源:互联网 发布:达内培训 编程k 编辑:程序博客网 时间:2024/06/06 03:09

通过 节,可以配置,在执行请求的过程中出现未处理的错误时要执行的操作。具体而言,
开发人员通过该节可配置要显示的 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>

具体页面路径自行更改。

阅读全文
0 0
原创粉丝点击