Server.GetLastError() gets exception details only in Page_Error and
Application_Error (if the error was not cleared in Page_Error). If you need
the exception details in the custom error's default redirect page, store the
exception in an application variable and access it in the custom error page
(without calling Server.ClearError in Application_Error and Page_Error).
"poifull" wrote:
> Hi all,
>
> I specified an aspx page in my web.config/customErrors tag to handle any
> error that might occur.
> When an exception is thrown, Server.GetLastError() returns null in the error
> handling page. Please let me know if my approach is wrong.
>
> Web.config:
> <customErrors defaultRedirect="ShowErrorMessage.aspx" mode="On" />
>
>
> ShowErrorMessage.aspx:
>
> protected void Page_Load(object sender, EventArgs e)
> {
>
> Response.Write(Server.GetLastError() == null); // prints True
>
> }
>
>
> Thanks in advance.
>
>
>
>
|