Ejemplo n.º 1
0
        public string Redirect(string url, IDictionary options)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(null);
            }

            Host host = Host.Get(Host.DefaultId) as Host;

            if (!url.StartsWith("~/"))
            {
                var index = url.IndexOf("~/");
                if (index < 0)
                {
                    return(null);
                }

                url = url.Substring(index);
            }

            string target = "local";

            if (options != null && options["Target"] != null)
            {
                target = options["Target"].ToString();
            }

            if (string.Compare(target, "host", true) == 0)
            {
                return(host.GetDirectEvolutionRedirectUrl(url));
            }
            else
            {
                string redirectUrl;
                if (_redirectionService.TryGetRedirectUrl(host, url, out redirectUrl))
                {
                    return(host.AbsoluteUrl(redirectUrl));
                }

                return(null);
            }
        }