HttpServerUtility.GetLastError Method

Definition

Returns the previous exception.

C#
public Exception GetLastError();

Returns

The previous exception that was thrown.

Examples

The following example prints a description of the application's last error to the HTTP output stream. It prints "No Errors" if no errors have been encountered.

C#
Exception LastError;
String ErrMessage;

LastError = Server.GetLastError();

if (LastError != null)
   ErrMessage = LastError.Message;
else
   ErrMessage = "No Errors";

Response.Write("Last Error = " + ErrMessage);

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also