本文整理汇总了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;
}