private string MakeUniqueUrl(string url)
        {
            var uri         = new UriBuilder(new Uri(Request.Url, url));
            var redirectUrl = uri.ToString();

            if (_cookieCultureService.GetSettings().EnforceCookieUrl)
            {
                var epIndex = redirectUrl.IndexOf('?');
                var qs      = new NameValueCollection();
                if (epIndex > 0)
                {
                    qs = HttpUtility.ParseQueryString(redirectUrl.Substring(epIndex));
                }

                // substract Epoch to get a smaller number
                var refresh = _clock.UtcNow.Ticks - Epoch;
                qs.Remove(RefreshKey);

                qs.Add(RefreshKey, refresh.ToString("x"));
                var querystring = "?" + string.Join("&", Array.ConvertAll(qs.AllKeys, k => string.Format("{0}={1}", HttpUtility.UrlEncode(k), HttpUtility.UrlEncode(qs[k]))));

                if (epIndex > 0)
                {
                    redirectUrl = redirectUrl.Substring(0, epIndex) + querystring;
                }
                else
                {
                    redirectUrl = redirectUrl + querystring;
                }
            }
            return(redirectUrl);
        }
Exemple #2
0
        public CultureSelectorResult GetCulture(HttpContextBase context)
        {
            var cultureCookie = _cookieCultureService.GetCulture();

            if (cultureCookie == null || string.Equals(cultureCookie, "Browser", StringComparison.InvariantCultureIgnoreCase))
            {
                return(null);
            }

            var cultureName = _cookieCultureService.GetSpecificOrNeutralCulture(cultureCookie);

            return(cultureName == null ? null : new CultureSelectorResult {
                Priority = _cookieCultureService.GetSettings().Priority, CultureName = cultureName
            });
        }