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


C# Response.AddCookie方法代码示例

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


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

示例1: Should_set_a_cookie_with_name_and_value

 public void Should_set_a_cookie_with_name_and_value()
 {
     var response = new Response();
     response.AddCookie("itsover", "9000");
     response.Cookies.Count.ShouldEqual(1);
     response.Cookies[0].ShouldEqual("itsover", "9000", null, null, null);
 }
开发者ID:sequoiar,项目名称:Nancy,代码行数:7,代码来源:ResponseFixture.cs

示例2: AuthenticateModule

        public AuthenticateModule()
            : base("/api")
        {
            Post["/AuthenticateUser"] = parameters =>
                {
                    var bind = this.Bind<LoginRequest>();

                    //do something with request.Username and request.Password.

                    var response = new Response
                        {
                            StatusCode = HttpStatusCode.OK
                        };

                    response.AddCookie("valid", bind.Username, DateTime.Now.AddMinutes(5));
                    return response;
                };
            Get["/LogOff"] = parameters =>
                {
                    var response = new Response
                        {
                            StatusCode = HttpStatusCode.OK
                        };

                    //clear the cookie
                    response.AddCookie("valid", null, DateTime.Now.AddYears(-5));
                    return response;
                };
        }
开发者ID:markcoleman,项目名称:AngularBlogPost,代码行数:29,代码来源:AuthenticateModule.cs

示例3: Should_set_a_cookie_with_name_and_value_and_expiry

 public void Should_set_a_cookie_with_name_and_value_and_expiry()
 {
     var response = new Response();
     var date = DateTime.Now;
     response.AddCookie("itsover", "9000", date);
     response.Cookies.Count.ShouldEqual(1);
     response.Cookies[0].ShouldEqual("itsover", "9000", date, null, null);
 }
开发者ID:sequoiar,项目名称:Nancy,代码行数:8,代码来源:ResponseFixture.cs

示例4: Should_set_a_cookie_with_everything

 public void Should_set_a_cookie_with_everything()
 {
     var response = new Response();
     var date = DateTime.Now;
     response.AddCookie("itsover", "9000", date, "life", "/andeverything");
     response.Cookies.Count.ShouldEqual(1);
     response.Cookies[0].ShouldEqual("itsover", "9000", date, "life", "/andeverything");
 }
开发者ID:sequoiar,项目名称:Nancy,代码行数:8,代码来源:ResponseFixture.cs

示例5: Should_set_a_cookie_with_everything

        public void Should_set_a_cookie_with_everything()
        {
			// Given
            var response = new Response();
            var date = DateTime.Now;
			
			// When
            response.AddCookie("itsover", "9000", date, "life", "/andeverything");
			
			// Then
            response.Cookies.Count.ShouldEqual(1);
            ValidateCookie(response.Cookies[0], "itsover", "9000", date, "life", "/andeverything");
        }
开发者ID:jbattermann,项目名称:Nancy,代码行数:13,代码来源:ResponseFixture.cs

示例6: Should_set_a_cookie_with_name_and_value_and_expiry

        public void Should_set_a_cookie_with_name_and_value_and_expiry()
        {
			// Given
            var response = new Response();
            var date = DateTime.Now;
			
			// When
            response.AddCookie("itsover", "9000", date);
			
			// Then
            response.Cookies.Count.ShouldEqual(1);
            ValidateCookie(response.Cookies[0], "itsover", "9000", date, null, null);
        }
开发者ID:jbattermann,项目名称:Nancy,代码行数:13,代码来源:ResponseFixture.cs

示例7: CookieResponse

 private static Response CookieResponse()
 {
     var response = new Response();
     response.AddCookie("marcusCookie", "42", tomorrow);
     return response;
 }
开发者ID:marcusoftnet,项目名称:DiscoveringNancyThroughTests,代码行数:6,代码来源:ResponseObjectProperites.cs


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