ASP.NET / Web.config: customErrors redirect only on a 404

前端 未结 2 2117
时光说笑
时光说笑 2021-02-14 02:05

I have this scenario:

A user comes to my site and follows a link, which doesn\'t exists anymore, he should be redirected to a custom errorpage. (that works)

If a u

相关标签:
2条回答
  • 2021-02-14 02:47

    Ray Van Halens Answer is correct, but this was not the actual problem.

    The reason for not showing stacktrace is a bug in mono itself. There is no other way then write an own error page where the stacktrace is dispayed.

    0 讨论(0)
  • 2021-02-14 02:58

    In the following web.config entries, a not found (404) condition will send a user to PageNotFound.aspx

    Use mode="Off" and everyone (local and remote users) will see error details.

    <customErrors mode="Off">
         <error statusCode="404" redirect="~/errorPages/PageNotFound.aspx" />
    </customErrors>
    

    Use mode="RemoteOnly" and local users will see detailed error pages with a stack trace and compilation details. Remote users with be presented with the GeneralError.aspx page

    <customErrors mode="RemoteOnly" defaultRedirect="~/errorPages/GeneralError.aspx">
         <error statusCode="404" redirect="~/errorPages/PageNotFound.aspx" />
    </customErrors>
    
    0 讨论(0)
提交回复
热议问题