コード例 #1
0
        private static void CookieHandler_OnEndRequest(object sender, EventArgs e)
        {
            try
            {
                var httpApplication = sender as HttpApplication;
                if (httpApplication == null)
                {
                    return;
                }

                var response = httpApplication.Response;
                if (response.Cookies.AllKeys.Contains("DNNPersonalization"))
                {
                    var cookiesValue = response.Cookies["DNNPersonalization"]?.Value;
                    if (!string.IsNullOrEmpty(cookiesValue) && IsPlainText(cookiesValue))
                    {
                        var encryptValue = new PortalSecurity().Encrypt(GetDecryptionkey(), cookiesValue);
                        response.Cookies["DNNPersonalization"].Value = encryptValue
                                                                       .Replace("/", "_")
                                                                       .Replace("+", "-")
                                                                       .Replace("=", "%3d");
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }