HttpListenerException Class

Definition

当处理 HTTP 请求出错时引发的异常。The exception that is thrown when an error occurs processing an HTTP request.

public ref class HttpListenerException : System::ComponentModel::Win32Exception
public class HttpListenerException : System.ComponentModel.Win32Exception
[System.Serializable]
public class HttpListenerException : System.ComponentModel.Win32Exception
type HttpListenerException = class
    inherit Win32Exception
Public Class HttpListenerException
Inherits Win32Exception
Inheritance
Attributes

Remarks

HttpListener 初始化期间或在创建或发送对 HTTP 请求的响应期间发生错误时,HttpListener 类及其关联类会引发此异常。This exception is thrown by the HttpListener class and its associated classes when an error occurs during initialization of the HttpListener or while creating or sending a response to an HTTP request. 例如,如果 HttpListener 尝试注册已注册的统一资源标识符(URI)前缀,则会引发此异常。For example, this exception is thrown if the HttpListener attempts to register a Uniform Resource Identifier (URI) prefix that is already registered.

相关提示Associated Tips

确保尝试注册的 URI 前缀尚未被注册。Make sure you are not attempting to register a URI prefix that is already registered.
如果 URI 前缀已被注册,将引发此异常。If the URI prefix is already registered, this exception will occur.

确保您的 HTTP 请求有效。Make sure your HTTP request is valid.
如果在 HttpListener 的初始化期间或在创建或发送对 HTTP 请求的响应时发生错误,HttpListener 类及其关联类将引发此异常。This exception is thrown by the HttpListener class and its associated classes when an error occurs during the initialization of the HttpListener or while creating or sending a response to an HTTP request.

如果要使用 HttpListenerPrefixCollection.Add 方法,请确保尚未添加该 uriPrefixIf you are using the HttpListenerPrefixCollection.Add method, make sure the uriPrefix has not been already added.
如果另一个 HttpListener 已经添加了前缀 uriPrefix,将引发此异常。This exception will be thrown if another HttpListener has already added the prefix uriPrefix.

Constructors

HttpListenerException()

初始化 HttpListenerException 类的新实例。Initializes a new instance of the HttpListenerException class.

HttpListenerException(Int32)

使用指定的错误代码初始化 HttpListenerException 类的新实例。Initializes a new instance of the HttpListenerException class using the specified error code.

HttpListenerException(Int32, String)

使用指定的错误代码和信息初始化 HttpListenerException 类的新实例。Initializes a new instance of the HttpListenerException class using the specified error code and message.

HttpListenerException(SerializationInfo, StreamingContext)

HttpListenerExceptionSerializationInfo 类的指定实例初始化 StreamingContext 类的新实例。Initializes a new instance of the HttpListenerException class from the specified instances of the SerializationInfo and StreamingContext classes.

Properties

Data

获取键/值对的集合,这些键/值对提供有关该异常的其他用户定义信息。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(Inherited from Exception)
ErrorCode

获取一个值,该值标识发生的错误。Gets a value that identifies the error that occurred.

HelpLink

获取或设置指向与此异常关联的帮助文件链接。Gets or sets a link to the help file associated with this exception.

(Inherited from Exception)
HResult

获取或设置 HRESULT(一个分配给特定异常的编码数字值)。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(Inherited from Exception)
InnerException

获取导致当前异常的 Exception 实例。Gets the Exception instance that caused the current exception.

(Inherited from Exception)
Message

获取描述当前异常的消息。Gets a message that describes the current exception.

(Inherited from Exception)
NativeErrorCode

获取与此异常关联的 Win32 错误代码。Gets the Win32 error code associated with this exception.

(Inherited from Win32Exception)
Source

获取或设置导致错误的应用程序或对象的名称。Gets or sets the name of the application or the object that causes the error.

(Inherited from Exception)
StackTrace

获取调用堆栈上的即时框架字符串表示形式。Gets a string representation of the immediate frames on the call stack.

(Inherited from Exception)
TargetSite

获取引发当前异常的方法。Gets the method that throws the current exception.

(Inherited from Exception)

Methods

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetBaseException()

当在派生类中重写时,返回 Exception,它是一个或多个并发的异常的根本原因。When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(Inherited from Exception)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext)

使用发生此 SerializationInfo 的文件名和行号设置 Win32Exception 对象。Sets the SerializationInfo object with the file name and line number at which this Win32Exception occurred.

(Inherited from Win32Exception)
GetType()

获取当前实例的运行时类型。Gets the runtime type of the current instance.

(Inherited from Exception)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

返回包含 NativeErrorCode 和/或 HResult 的字符串。Returns a string that contains the NativeErrorCode, or HResult, or both.

(Inherited from Win32Exception)

Events

SerializeObjectState

当异常被序列化用来创建包含有关该异常的徐列出数据的异常状态对象时会出现该问题。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(Inherited from Exception)

Applies to

See also