本文整理匯總了C#中System.Web.HttpResponseBase.AppendCookie方法的典型用法代碼示例。如果您正苦於以下問題:C# HttpResponseBase.AppendCookie方法的具體用法?C# HttpResponseBase.AppendCookie怎麽用?C# HttpResponseBase.AppendCookie使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Web.HttpResponseBase
的用法示例。
在下文中一共展示了HttpResponseBase.AppendCookie方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddCookie
public static void AddCookie(HttpResponseBase Response, string name, string value, int day, int hours, int minutes, int seconds)
{
HttpCookie cookie = new HttpCookie(name);
TimeSpan ts = new TimeSpan(day, hours, minutes, seconds);
cookie.Expires = DateTime.Now.Add(ts);
cookie.Value = value;
Response.AppendCookie(cookie);
}
示例2: PrepareResponse
private void PrepareResponse(HttpResponseBase response, string downloadTokenValue, string zipFilename)
{
response.ContentType = "application/zip";
if (string.IsNullOrEmpty(downloadTokenValue) == false)
{
//downloadTokenValue will have been provided in the form submit via the hidden input field
response.AppendCookie(new HttpCookie("fileDownloadToken", downloadTokenValue));
}
response.AddHeader("content-disposition",
string.Format("attachment; filename={0}.zip", zipFilename));
}
示例3: ValidateUser
/// <summary>
/// Authenticates a user via the MembershipProvider and creates the associated forms authentication ticket.
/// </summary>
/// <param name="logon">Logon</param>
/// <param name="response">HttpResponseBase</param>
/// <returns>bool</returns>
public static bool ValidateUser(Logon logon, HttpResponseBase response)
{
bool result = false;
if (Membership.ValidateUser(logon.Username, logon.Password))
{
// Create the authentication ticket with custom user data.
var serializer = new JavaScriptSerializer();
string userData = serializer.Serialize(UserManager.User);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
logon.Username,
DateTime.Now,
DateTime.Now.AddDays(30),
true,
userData,
FormsAuthentication.FormsCookiePath);
// Encrypt the ticket.
string encTicket = FormsAuthentication.Encrypt(ticket);
//encTicket = ZipLib.Zip(encTicket);
// Create the cookie.
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName);
cookie.Expires = DateTime.Now.AddDays(1);
cookie.Value = encTicket;
response.AppendCookie(cookie);
//response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
result = true;
}
return result;
}