CookieException CookieException CookieException CookieException Class

定義

Cookie 加入 CookieContainer 卻發生錯誤時,所擲回的例外狀況。The exception that is thrown when an error is made adding a Cookie to a CookieContainer.

public ref class CookieException : FormatException
[System.Serializable]
public class CookieException : FormatException
type CookieException = class
    inherit FormatException
    interface ISerializable
Public Class CookieException
Inherits FormatException
繼承
屬性
實作

備註

Add如果嘗試Cookie對長度大於MaxCookieSizeCookieContainer, 則會擲回這個例外狀況。This exception is thrown if an attempt is made to Add a Cookie with length greater than MaxCookieSize to a CookieContainer.

相關秘訣Associated Tips

請確定 cookie 大小未超過 cookie 容器允許的最大值。Make sure the cookie size does not exceed the maximum allowed by the cookie container.
嘗試將長度超過 CookieMaxCookieSize 加入至 CookieContainer,就會擲回這個例外狀況。This exception is thrown when an attempt is made to add a Cookie with length greater than MaxCookieSize to a CookieContainer. Cookie 大小的預設最大值為 4096 位元組。The default maximum cookie size is 4096 bytes.

設定 cookie 的 Name 屬性時, 請確定該值不是 null 參考或空字串。When setting the Name property for a cookie, make sure the value is not a null reference or empty string.
使用 Name 類別的執行個體之前,必須先初始化 Cookie 屬性。The Name property must be initialized before using an instance of the Cookie class. 下列字元是保留字,無法用於這個屬性值中:等號 (=)、逗號 (,)、新行 (\n)、換行符號 (\r),和定位點 (\t)。The following characters are reserved and cannot be used for this attribute value: equal sign, semicolon, comma, new line (\n), carriage return (\r), tab (\t). 第一個字元不能是貨幣符號 ($) 字元。The dollar sign ($) character cannot be the first character.

設定 cookie 的 Port 屬性時, 請確定值有效, 並以雙引號括住。When setting the Port property for a cookie, make sure the value is valid and enclosed in double quotes.
Port 屬性可以限制傳送 Cookie 的通訊埠。The Port attribute restricts the ports to which a cookie may be sent. 預設值為沒有限制。The default value means no restriction. 將這個屬性設定為空字串 ("") 會將通訊埠限制為 HTTP 回應中所使用的通訊埠。Setting the property to an empty string ("") restricts the port to the one used in the HTTP response. 否則該值必須是置於引號內的字串,其中包含以逗號區隔的通訊埠值。Otherwise the value must be a string in quotation marks that contains port values delineated with commas.

設定 cookie 的 Value 屬性時, 請確定該值不是 null。When setting the Value property for a cookie, make sure the value is not null.
下列字元是保留字,無法用於這個屬性:分號 (;) 和逗號 (,)。The following characters are reserved and cannot be used for this property: semicolon, comma.

建構函式

CookieException() CookieException() CookieException() CookieException()

初始化 CookieException 類別的新執行個體。Initializes a new instance of the CookieException class.

CookieException(SerializationInfo, StreamingContext) CookieException(SerializationInfo, StreamingContext) CookieException(SerializationInfo, StreamingContext) CookieException(SerializationInfo, StreamingContext)

使用 serializationInfostreamingContext 的指定值,初始化 CookieException 類別的新執行個體。Initializes a new instance of the CookieException class with specific values of serializationInfo and streamingContext.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetBaseException() GetBaseException() GetBaseException() GetBaseException()

在衍生類別中覆寫時,傳回一或多個後續的例外狀況的根本原因 ExceptionWhen overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(Inherited from Exception)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

以序列化 SerializationInfo 所需的資料填入 CookieException 執行個體。Populates a SerializationInfo instance with the data needed to serialize the CookieException.

GetType() GetType() GetType() GetType()

取得目前執行個體的執行階段類型。Gets the runtime type of the current instance.

(Inherited from Exception)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

建立並傳回目前例外狀況的字串表示。Creates and returns a string representation of the current exception.

(Inherited from Exception)

明確介面實作

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

以序列化 SerializationInfo 所需的資料填入 CookieException 執行個體。Populates a SerializationInfo instance with the data needed to serialize the CookieException.

屬性

Data Data Data Data

取得提供例外狀況之其他使用者定義相關資訊的索引鍵/值組集合。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(Inherited from Exception)
HelpLink HelpLink HelpLink HelpLink

取得或設定與這個例外狀況相關聯的說明檔連結。Gets or sets a link to the help file associated with this exception.

(Inherited from Exception)
HResult HResult HResult HResult

取得或設定 HRESULT,它是指派給特定例外狀況的編碼數值。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(Inherited from Exception)
InnerException InnerException InnerException InnerException

取得造成目前例外狀況的 Exception 執行個體。Gets the Exception instance that caused the current exception.

(Inherited from Exception)
Message Message Message Message

取得描述目前例外狀況的訊息。Gets a message that describes the current exception.

(Inherited from Exception)
Source Source Source Source

取得或設定造成錯誤的應用程式或物件的名稱。Gets or sets the name of the application or the object that causes the error.

(Inherited from Exception)
StackTrace StackTrace StackTrace StackTrace

取得呼叫堆疊上即時運算框架的字串表示。Gets a string representation of the immediate frames on the call stack.

(Inherited from Exception)
TargetSite TargetSite TargetSite TargetSite

取得擲回目前例外狀況的方法。Gets the method that throws the current exception.

(Inherited from Exception)

事件

SerializeObjectState SerializeObjectState SerializeObjectState SerializeObjectState

當例外狀況序列化,以建立包含例外狀況相關序列化資料的例外狀況狀態物件時,就會發生此事件。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(Inherited from Exception)

適用於

另請參閱