Method
HttpResponseExtensions.WithCookie<THttpResponse>
WithCookie<THttpResponse>(THttpResponse, string, string, DateTime?, TimeSpan?, string?, string?, bool?, bool?, string?) #
Adds a cookie to the HTTP response with specified parameters.
public static HttpResponse WithCookie<THttpResponse>(this THttpResponse response, string name, string value, DateTime? expires = null, TimeSpan? maxAge = null, string? domain = null, string? path = null, bool? secure = null, bool? httpOnly = null, string? sameSite = null) where THttpResponse : notnull, HttpResponseParameters #
response THttpResponse
name string
The name of the cookie.
value string
The value of the cookie.
expires DateTime?
The expiration date and time of the cookie. Can be null.
maxAge TimeSpan?
The maximum age of the cookie in seconds. Can be null.
domain string?
The domain for which the cookie is valid. Can be null.
path string?
The path for which the cookie is valid. Can be null.
secure bool?
A value indicating whether the cookie should only be sent over HTTPS. Can be null.
httpOnly bool?
A value indicating whether the cookie should be inaccessible to client-side scripts. Can be null.
sameSite string?
The SameSite attribute for the cookie. Can be null.
Returns #
The modified HTTP response.
Type Parameters #
THttpResponse
WithCookie<THttpResponse>(THttpResponse, Cookie) #
Adds a cookie to the HTTP response using a Cookie object.
public static HttpResponse WithCookie<THttpResponse>(this THttpResponse response, Cookie cookie) where THttpResponse : notnull, HttpResponseParameters #
response THttpResponse
cookie Cookie
The Cookie object to add.
Returns #
The modified HTTP response.
Type Parameters #
THttpResponse