HttpCookie.SameSite 屬性

定義

取得或設定 Cookie 的 SameSite 屬性值。Gets or sets the value for the SameSite attribute of the cookie.

public:
 property System::Web::SameSiteMode SameSite { System::Web::SameSiteMode get(); void set(System::Web::SameSiteMode value); };
public System.Web.SameSiteMode SameSite { get; set; }
member this.SameSite : System.Web.SameSiteMode with get, set
Public Property SameSite As SameSiteMode

屬性值

SameSiteMode

其中一個列舉值,表示 cookie 的強制模式,或 (由 (SameSiteMode)(-1) Unspecified 設定檔) 中的字串表示。One of the enumeration values that represents the enforcement mode of the cookie or (SameSiteMode)(-1) (represented by the string Unspecified in config files). 預設值取決於更新。The default value depends on updates. 如需預設值和最新更新的詳細資訊,請參閱備註。For more information on defaults and recent updates, see Remarks.

備註

此屬性的預設值是由 知識庫文章 4531182知識庫文章 4524421中所述的更新所修改。The default value of this property was modifed by updates described in KB article 4531182 and KB article 4524421.

如果沒有這些更新,預設值是 SameSiteMode.None ,它不會發出 SameSite cookie 標頭。Without these updates, the default value is SameSiteMode.None, which does not emit the SameSite cookie header. 這符合 https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1This conforms to https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1.

套用這些更新之後,預設值是 (SameSiteMode)(-1) ,它會對應至 UnspecifiedAfter these updates have been applied, the default value is (SameSiteMode)(-1), which corresponds to Unspecified. 這會保留先前的行為。This preserves the earlier behavior. 設定 SameSiteMode.None 會導致發出 "SameSite = None"。Setting SameSiteMode.None causes "SameSite=None" to be emitted. 這個新行為符合 https://tools.ietf.org/html/draft-west-cookie-incrementalism-00This new behavior conforms to https://tools.ietf.org/html/draft-west-cookie-incrementalism-00.

適用於