本文整理汇总了C#中Response.Cookies方法的典型用法代码示例。如果您正苦于以下问题:C# Response.Cookies方法的具体用法?C# Response.Cookies怎么用?C# Response.Cookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response.Cookies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ignoresEmptySetCookies
public void ignoresEmptySetCookies()
{
// prep http response header map
var headers = new System.Net.WebHeaderCollection();
headers["Set-Cookie"] = string.Empty;
Response res = new Response();
res.ProcessResponseHeaders(headers);
Assert.AreEqual(0, res.Cookies().Count);
}
示例2: ignoresEmptyCookieNameAndVals
public void ignoresEmptyCookieNameAndVals()
{
// prep http response header map
var headers = new System.Net.WebHeaderCollection();
var cookieStrings = new List<string>();
cookieStrings.Add(null);
cookieStrings.Add("");
cookieStrings.Add("one");
cookieStrings.Add("two=");
cookieStrings.Add("three=");
cookieStrings.Add("four=data; Domain=.example.com; Path=/");
headers.Set("Set-Cookie", cookieStrings.Join(";"));
var res = new Response();
res.ProcessResponseHeaders(headers);
Assert.AreEqual(4, res.Cookies().Count);
Assert.AreEqual(string.Empty, res.Cookie("one"));
Assert.AreEqual(string.Empty, res.Cookie("two"));
Assert.AreEqual(string.Empty, res.Cookie("three"));
Assert.AreEqual("data", res.Cookie("four"));
}
示例3: ignoresEmptyCookieNameAndVals
public void ignoresEmptyCookieNameAndVals()
{
// prep http response header map
System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection();
headers.Set("Set-Cookie", "one;two=;three=;four=data; Domain=.example.com; Path=/");
Response res = new Response();
res.ProcessResponseHeaders(headers);
Assert.AreEqual(4, res.Cookies().Count);
Assert.AreEqual("", res.Cookie("one"));
Assert.AreEqual("", res.Cookie("two"));
Assert.AreEqual("", res.Cookie("three"));
Assert.AreEqual("data", res.Cookie("four"));
}