HttpServerUtility.GetLastError HttpServerUtility.GetLastError HttpServerUtility.GetLastError HttpServerUtility.GetLastError Method

定义

返回前一个异常。Returns the previous exception.

public:
 Exception ^ GetLastError();
public Exception GetLastError ();
member this.GetLastError : unit -> Exception
Public Function GetLastError () As Exception

返回

引发的前一个异常。The previous exception that was thrown.

示例

下面的示例将打印到 HTTP 输出流的应用程序的最后一个错误的说明。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.

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

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

Response.Write("Last Error = " + ErrMessage);
   
Dim LastError As Exception
Dim ErrMessage As String

LastError = Server.GetLastError()

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

适用于

另请参阅