Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HttpServerUtility.GetLastError Method

Returns the previous exception.

[Visual Basic]
Public Function GetLastError() As Exception
public Exception GetLastError();
public: Exception* GetLastError();
public function GetLastError() : Exception;

Return Value

The previous exception that was thrown.


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.

[Visual Basic] 
Dim LastError As Exception
Dim ErrMessage As String

LastError = Server.GetLastError()

If Not LastError Is Nothing Then
   ErrMessage = LastError.Message
   ErrMessage = "No Errors"
End If
Response.Write("Last Error = " & ErrMessage)

Exception LastError;
String ErrMessage;
LastError = Server.GetLastError();

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

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

Exception* LastError;
String* ErrMessage;

LastError = Server->GetLastError();

if (LastError != 0)
   ErrMessage = LastError->Message;
   ErrMessage = S"No Errors";

Response->Write(String::Format(S"Last Error = {0}", ErrMessage));

var lastError : Exception
var errMessage : String

lastError = Server.GetLastError()

if(lastError != null)
   errMessage = lastError.Message
   errMessage = "No Errors"
Response.Write("Last Error = " + errMessage)


Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpServerUtility Class | HttpServerUtility Members | System.Web Namespace

© 2015 Microsoft