Beispiel #1
0
        /// <summary>
        /// Generates redirect location by specified parameters
        /// </summary>
        protected virtual string GetRedirectedRequestUrl(string asproxyPage, string destination, string referrer, string webMethod, bool encodeUrl)
        {
            // Encode redirect page if needed
            if (encodeUrl)
            {
                destination = UrlProvider.EncodeUrl(destination);

                if (!string.IsNullOrEmpty(referrer))
                {
                    referrer = UrlProvider.EncodeUrl(referrer);
                }
            }
            else
            {
                // just make it url safe
                destination = UrlProvider.EscapeUrlQuery(destination);

                if (!string.IsNullOrEmpty(referrer))
                {
                    referrer = UrlProvider.EscapeUrlQuery(referrer);
                }
            }

            // If address exists in current page address it will automatically replaced
            asproxyPage = UrlBuilder.AddUrlQuery(asproxyPage, Consts.Query.UrlAddress, destination);

            // Apply decode option
            asproxyPage = UrlBuilder.AddUrlQuery(asproxyPage,
                                                 Consts.Query.Decode,
                                                 Convert.ToByte(encodeUrl).ToString());

            // Apply current page as referrer url for redirect url
            if (!string.IsNullOrEmpty(referrer))
            {
                asproxyPage = UrlBuilder.AddUrlQueryToEnd(asproxyPage, Consts.Query.Redirect, referrer);
            }

            // If page is marked as posted back, remove the remark
            if (string.IsNullOrEmpty(webMethod))
            {
                // The default web method will be used
                asproxyPage = UrlBuilder.RemoveQuery(asproxyPage, Consts.Query.WebMethod);
            }
            else
            {
                // changing the web method
                asproxyPage = UrlBuilder.ReplaceUrlQuery(asproxyPage, Consts.Query.WebMethod, webMethod);
            }

            return(asproxyPage);
        }