public static AddHeader ( string[]>.this |
||
headers | string[]>.this | |
name | string | |
value | string | |
return | string[]>.IDictionary |
public Response SetCookie(string key, Cookie cookie) { var domainHasValue = !string.IsNullOrEmpty(cookie.Domain); var pathHasValue = !string.IsNullOrEmpty(cookie.Path); var expiresHasValue = cookie.Expires.HasValue; var setCookieValue = string.Concat( Uri.EscapeDataString(key), "=", Uri.EscapeDataString(cookie.Value ?? ""), !domainHasValue ? null : "; domain=", !domainHasValue ? null : cookie.Domain, !pathHasValue ? null : "; path=", !pathHasValue ? null : cookie.Path, !expiresHasValue ? null : "; expires=", !expiresHasValue ? null : cookie.Expires.Value.ToString("ddd, dd-MMM-yyyy HH:mm:ss ") + "GMT", !cookie.Secure ? null : "; secure", !cookie.HttpOnly ? null : "; HttpOnly" ); Headers.AddHeader("Set-Cookie", setCookieValue); return(this); }
public Response SetCookie(string key, string value) { Headers.AddHeader("Set-Cookie", Uri.EscapeDataString(key) + "=" + Uri.EscapeDataString(value) + "; path=/"); return(this); }