If my web.config has:
<customErrors mode="Off" defaultRedirect="CustomErrorPage.aspx">
<error statusCode="401" redirect="~/CustomErrorPage.aspx?statusCode=401" />
<error statusCode="403" redirect="~/CustomErrorPage.aspx?statusCode=403" />
<error statusCode="404" redirect="~/CustomErrorPage.aspx?statusCode=404" />
...
</customErrors>
Now in my CustomErrorPage.aspx, how can I get the stacktrace information similar to how I see that yellow screen error page when there is no custom error page and it is outputted to the browser?
Or, because this is redirecting to the customerrorpage.aspx, is the error essentially lost at this point and I can’t access the exception information?
This is a legacy application with complex virtual directories etc. so I can just drop one of those error libraries so easily at this point.
It’s lost. You aren’t even in the same request, since it’s done by a redirect.
That last point is bad enough in itself (what’s the point of redirecting someone to an error page?), but it affects you here. However, with
redirectMode="ResponseRewrite"added to thecustomErrorselement, then that solves this problem and also means thatServer.GetLastError()will work.