当前位置: 首页>>代码示例>>C#>>正文


C# HttpCookie.ToString方法代码示例

本文整理汇总了C#中System.Web.HttpCookie.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# HttpCookie.ToString方法的具体用法?C# HttpCookie.ToString怎么用?C# HttpCookie.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpCookie的用法示例。


在下文中一共展示了HttpCookie.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: isallow

 private bool isallow(HttpCookie cook)
 {
     if (cook != null)
     {
         if (cook.ToString() != "")
         {
             return true;
         }
     }
     return false;
 }
开发者ID:caowujun,项目名称:BootstrapMvc2015GitHub,代码行数:11,代码来源:CustomAuthorizeAttribute.cs

示例2: ToStringTest

		[Test] // bug #81333
		public void ToStringTest ()
		{
			HttpCookie cookie;

			cookie = new HttpCookie ("cookie1", "this x=y is the & first = cookie");
			Assert.AreEqual ("System.Web.HttpCookie", cookie.ToString (), "#A1");
			Assert.AreEqual ("this x=y is the & first = cookie", cookie.Value, "#A2");
			Assert.AreEqual (2, cookie.Values.Count, "#A3");
			Assert.AreEqual ("this x", cookie.Values.GetKey (0), "#A4");
			Assert.AreEqual ("y is the ", cookie.Values.Get (0), "#A5");
			Assert.AreEqual (" first ", cookie.Values.GetKey (1), "#A6");
			Assert.AreEqual (" cookie", cookie.Values.Get (1), "#A7");
			Assert.AreEqual ("this+x=y+is+the+&+first+=+cookie",
				cookie.Values.ToString (), "#A8");

			cookie = new HttpCookie ("cookie11", cookie.Values.ToString ());
			Assert.AreEqual ("System.Web.HttpCookie", cookie.ToString (), "#B1");
			Assert.AreEqual ("this+x=y+is+the+&+first+=+cookie", cookie.Value, "#B2");
			Assert.AreEqual (2, cookie.Values.Count, "#B3");
			Assert.AreEqual ("this+x", cookie.Values.GetKey (0), "#B4");
			Assert.AreEqual ("y+is+the+", cookie.Values.Get (0), "#B5");
			Assert.AreEqual ("+first+", cookie.Values.GetKey (1), "#B6");
			Assert.AreEqual ("+cookie", cookie.Values.Get (1), "#B7");
			Assert.AreEqual ("this%2bx=y%2bis%2bthe%2b&%2bfirst%2b=%2bcookie",
				cookie.Values.ToString (), "#B8");

			cookie = new HttpCookie ("cookie2");
			cookie.Values ["first"] = "hell=o = y";
			cookie.Values ["second"] = "the&re";
			cookie.Values ["third"] = "three";
			cookie.Values ["three-a"] = null;
			cookie.Values ["fourth"] = "last value";
			Assert.AreEqual ("System.Web.HttpCookie", cookie.ToString (), "#C1");
			Assert.AreEqual ("first=hell=o = y&second=the&re&third=three&three"
				+ "-a=&fourth=last value", cookie.Value, "#C2");
			Assert.AreEqual (5, cookie.Values.Count, "#C3");
			Assert.AreEqual ("first", cookie.Values.GetKey (0), "#C4");
			Assert.AreEqual ("hell=o = y", cookie.Values.Get (0), "#C5");
			Assert.AreEqual ("second", cookie.Values.GetKey (1), "#C6");
			Assert.AreEqual ("the&re", cookie.Values.Get (1), "#C7");
			Assert.AreEqual ("third", cookie.Values.GetKey (2), "#C8");
			Assert.AreEqual ("three", cookie.Values.Get (2), "#C9");
			Assert.AreEqual ("three-a", cookie.Values.GetKey (3), "#C10");
			Assert.IsNull (cookie.Values.Get (3), "#C11");
			Assert.AreEqual ("fourth", cookie.Values.GetKey (4), "#C12");
			Assert.AreEqual ("last value", cookie.Values.Get (4), "#C13");
			Assert.AreEqual ("first=hell%3do+%3d+y&second=the%26re&third=three"
				+ "&three-a=&fourth=last+value", cookie.Values.ToString (), "#C14");

			cookie = new HttpCookie ("cookie21", cookie.Values.ToString ());
			Assert.AreEqual ("System.Web.HttpCookie", cookie.ToString (), "#D1");
			Assert.AreEqual ("first=hell%3do+%3d+y&second=the%26re&third=three"
				+ "&three-a=&fourth=last+value", cookie.Value, "#D2");
			Assert.AreEqual (5, cookie.Values.Count, "#D3");
			Assert.AreEqual ("first", cookie.Values.GetKey (0), "#D4");
			Assert.AreEqual ("hell%3do+%3d+y", cookie.Values.Get (0), "#D5");
			Assert.AreEqual ("second", cookie.Values.GetKey (1), "#D6");
			Assert.AreEqual ("the%26re", cookie.Values.Get (1), "#D7");
			Assert.AreEqual ("third", cookie.Values.GetKey (2), "#D8");
			Assert.AreEqual ("three", cookie.Values.Get (2), "#D9");
			Assert.AreEqual ("three-a", cookie.Values.GetKey (3), "#D10");
			Assert.AreEqual ("three-a", cookie.Values.GetKey (3), "#D11");
			Assert.AreEqual ("fourth", cookie.Values.GetKey (4), "#D12");
			Assert.AreEqual ("last+value", cookie.Values.Get (4), "#D13");
			Assert.AreEqual ("first=hell%253do%2b%253d%2by&second=the%2526re&"
				+ "third=three&three-a=&fourth=last%2bvalue",
				cookie.Values.ToString (), "#D14");

			cookie = new HttpCookie ("cookie3", "this is & the x=y third = cookie");
			cookie.Values ["first"] = "hel&l=o =y";
			cookie.Values ["second"] = "there";
			Assert.AreEqual ("System.Web.HttpCookie", cookie.ToString (), "#E1");
			Assert.AreEqual ("this is & the x=y third = cookie&first=hel&l=o =y"
				+ "&second=there", cookie.Value, "#E2");
			Assert.AreEqual (4, cookie.Values.Count, "#E3");
			Assert.IsNull (cookie.Values.GetKey (0), "#E4");
			Assert.AreEqual ("this is ", cookie.Values.Get (0), "#E5");
			Assert.AreEqual (" the x", cookie.Values.GetKey (1), "#E6");
			Assert.AreEqual ("y third = cookie", cookie.Values.Get (1), "#E7");
			Assert.AreEqual ("first", cookie.Values.GetKey (2), "#E8");
			Assert.AreEqual ("hel&l=o =y", cookie.Values.Get (2), "#E9");
			Assert.AreEqual ("second", cookie.Values.GetKey (3), "#E10");
			Assert.AreEqual ("there", cookie.Values.Get (3), "#E11");
			Assert.AreEqual ("this+is+&+the+x=y+third+%3d+cookie&first=hel%26l"
				+ "%3do+%3dy&second=there", cookie.Values.ToString (), "#E12");

			cookie = new HttpCookie ("cookie31", cookie.Values.ToString ());
			Assert.AreEqual ("System.Web.HttpCookie", cookie.ToString (), "#F1");
			Assert.AreEqual ("this+is+&+the+x=y+third+%3d+cookie&first=hel%26l"
				+ "%3do+%3dy&second=there", cookie.Value, "#F2");
			Assert.AreEqual (4, cookie.Values.Count, "#F3");
			Assert.IsNull (cookie.Values.GetKey (0), "#F4");
			Assert.AreEqual ("this+is+", cookie.Values.Get (0), "#F5");
			Assert.AreEqual ("+the+x", cookie.Values.GetKey (1), "#F6");
			Assert.AreEqual ("y+third+%3d+cookie", cookie.Values.Get (1), "#F7");
			Assert.AreEqual ("first", cookie.Values.GetKey (2), "#F8");
			Assert.AreEqual ("hel%26l%3do+%3dy", cookie.Values.Get (2), "#F9");
			Assert.AreEqual ("second", cookie.Values.GetKey (3), "#F10");
			Assert.AreEqual ("there", cookie.Values.Get (3), "#F11");
//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:HttpCookieTest.cs


注:本文中的System.Web.HttpCookie.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。