本文整理匯總了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);
}
示例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;
};
}
示例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);
}
示例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");
}
示例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");
}
示例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);
}
示例7: CookieResponse
private static Response CookieResponse()
{
var response = new Response();
response.AddCookie("marcusCookie", "42", tomorrow);
return response;
}