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


C# HttpCookie.ToHeaderString方法代码示例

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


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

示例1: ToHeaderString_SingleValueWithWhiteSpace_Formatting

        public void ToHeaderString_SingleValueWithWhiteSpace_Formatting()
        {
            string name = "foobar";
            string value = "the value";
            var cookie = new HttpCookie(name, value);

            string header = cookie.ToHeaderString();
            Assert.AreEqual("Set-Cookie: foobar=\"the value\"\r\n", header);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:9,代码来源:HttpCookieTest.cs

示例2: ToHeaderString_NameWithComma_Formatting

        public void ToHeaderString_NameWithComma_Formatting()
        {
            string name = "foo,bar";
            string value = "value";
            var cookie = new HttpCookie(name, value);

            string header = cookie.ToHeaderString();
            Assert.AreEqual("Set-Cookie: \"foo,bar\"=value\r\n", header);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:9,代码来源:HttpCookieTest.cs

示例3: ToHeaderString_SingleValueWithSemiColon_Formatting

        public void ToHeaderString_SingleValueWithSemiColon_Formatting()
        {
            string name = "foobar";
            string value = "value;";
            var cookie = new HttpCookie(name, value);

            string header = cookie.ToHeaderString();
            Assert.AreEqual("Set-Cookie: foobar=\"value;\"\r\n", header);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:9,代码来源:HttpCookieTest.cs

示例4: ToHeaderString_NameValueAndPath_Formatting

        public void ToHeaderString_NameValueAndPath_Formatting()
        {
            string name = "foobar";
            string value = "value";
            var cookie = new HttpCookie(name, value);

            cookie.Path = "/foobar/";

            string header = cookie.ToHeaderString();
            Assert.AreEqual("Set-Cookie: foobar=value; path=/foobar/\r\n", header);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:11,代码来源:HttpCookieTest.cs

示例5: ToHeaderString_NameValueAndSecure_Formatting

        public void ToHeaderString_NameValueAndSecure_Formatting()
        {
            string name = "foobar";
            string value = "value";
            var cookie = new HttpCookie(name, value);

            cookie.Secure = true;

            string header = cookie.ToHeaderString();
            Assert.AreEqual("Set-Cookie: foobar=value; secure\r\n", header);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:11,代码来源:HttpCookieTest.cs

示例6: ToHeaderString_NameValueAndExpires_Formatting

        public void ToHeaderString_NameValueAndExpires_Formatting()
        {
            string name = "foobar";
            string value = "value";
            var cookie = new HttpCookie(name, value);

            cookie.Expires = new DateTime(2010, 8, 4, 10, 11, 12, DateTimeKind.Utc);

            string header = cookie.ToHeaderString();
            Assert.AreEqual("Set-Cookie: foobar=value; expires=Wed, 04 Aug 2010 10:11:12 GMT\r\n", header);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:11,代码来源:HttpCookieTest.cs

示例7: ToHeaderString_NameValueAndDomain_Formatting

        public void ToHeaderString_NameValueAndDomain_Formatting()
        {
            string name = "foobar";
            string value = "value";
            var cookie = new HttpCookie(name, value);

            cookie.Domain = "http://manos-de-mono.com";

            string header = cookie.ToHeaderString();
            Assert.AreEqual("Set-Cookie: foobar=value; domain=http://manos-de-mono.com\r\n", header);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:11,代码来源:HttpCookieTest.cs

示例8: ToHeaderString_SingleValueWithComma_Formatting

        public void ToHeaderString_SingleValueWithComma_Formatting()
        {
            var name = "foobar";
            var value = "val,ue";
            var cookie = new HttpCookie (name, value);

            var header = cookie.ToHeaderString ();
            Assert.AreEqual ("Set-Cookie: foobar=\"val,ue\"\r\n", header);
        }
开发者ID:KevinT,项目名称:manos,代码行数:9,代码来源:HttpCookieTest.cs

示例9: ToHeaderString_SingleValueNoWhiteSpace_Formatting

        public void ToHeaderString_SingleValueNoWhiteSpace_Formatting()
        {
            var name = "foobar";
            var value = "value";
            var cookie = new HttpCookie (name, value);

            var header = cookie.ToHeaderString ();
            Assert.AreEqual ("Set-Cookie: foobar=value\r\n", header);
        }
开发者ID:KevinT,项目名称:manos,代码行数:9,代码来源:HttpCookieTest.cs

示例10: ToHeaderString_NameValueAndHttpOnly_Formatting

        public void ToHeaderString_NameValueAndHttpOnly_Formatting()
        {
            var name = "foobar";
            var value = "value";
            var cookie = new HttpCookie (name, value);

            cookie.HttpOnly = true;

            var header = cookie.ToHeaderString ();
            Assert.AreEqual ("Set-Cookie: foobar=value; HttpOnly\r\n", header);
        }
开发者ID:KevinT,项目名称:manos,代码行数:11,代码来源:HttpCookieTest.cs


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