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


C# HttpResponseBase.AppendCookie方法代码示例

本文整理汇总了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);
 }
开发者ID:the404,项目名称:xyz,代码行数:8,代码来源:CookieHelper.cs

示例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));
        }
开发者ID:gbanister,项目名称:Viewer,代码行数:13,代码来源:IOutputZipResponse.cs

示例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;
        }
开发者ID:dalinhuang,项目名称:myecms,代码行数:42,代码来源:UserManager.cs


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