@@ -115,22 +115,27 @@ public Cookie(string name, string value, string domain, string path, DateTime? e
115115 /// <param name="isSecure"><see langword="true"/> if the cookie is secure; otherwise <see langword="false"/></param>
116116 /// <param name="isHttpOnly"><see langword="true"/> if the cookie is an HTTP-only cookie; otherwise <see langword="false"/></param>
117117 /// <param name="sameSite">The SameSite value of cookie.</param>
118- /// <exception cref="ArgumentException">If the name is <see langword="null"/> or an empty string,
119- /// or if it contains a semi-colon.</exception>
120- /// <exception cref="ArgumentNullException">If the value or currentUrl is <see langword="null"/>.</exception>
118+ /// <exception cref="ArgumentException">If the name and value are both an empty string,
119+ /// or if the name contains a semi-colon.</exception>
120+ /// <exception cref="ArgumentNullException">If the name, value or currentUrl is <see langword="null"/>.</exception>
121121 /// <exception cref="ArgumentNullException">If the same site value is not valid or same site value is "None" but secure is set to false.</exception>
122122 public Cookie ( string name , string value , string domain , string path , DateTime ? expiry , bool secure , bool isHttpOnly , string sameSite )
123123 {
124- if ( string . IsNullOrEmpty ( name ) )
124+ if ( name == null )
125125 {
126- throw new ArgumentException ( "Cookie name cannot be null or empty string" , nameof ( name ) ) ;
126+ throw new ArgumentNullException ( nameof ( value ) , "Cookie name cannot be null" ) ;
127127 }
128128
129129 if ( value == null )
130130 {
131131 throw new ArgumentNullException ( nameof ( value ) , "Cookie value cannot be null" ) ;
132132 }
133133
134+ if ( name == string . Empty && value == string . Empty )
135+ {
136+ throw new ArgumentException ( "Cookie name and value cannot both be empty string" ) ;
137+ }
138+
134139 if ( name . IndexOf ( ';' ) != - 1 )
135140 {
136141 throw new ArgumentException ( "Cookie names cannot contain a ';': " + name , nameof ( name ) ) ;
0 commit comments