當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。