AddQueryParameters() public method

public AddQueryParameters ( NameValueCollection parameters ) : void
parameters System.Collections.Specialized.NameValueCollection
return void
Beispiel #1
0
 /// <summary>
 ///     Redirect to page with query string parameter returnUrl
 /// </summary>
 /// <param name="pageId"></param>
 /// <param name="returnUrl"></param>
 public static bool Redirect(Guid pageId, string returnUrl)
 {
     string pageUrl;
     PageStructureInfo.TryGetPageUrl(pageId, out pageUrl);
     if (!string.IsNullOrEmpty(pageUrl))
     {
         if (!string.IsNullOrEmpty(returnUrl))
         {
             var urlBuilder = new UrlBuilder(pageUrl);
             var queryParameters = new NameValueCollection();
             queryParameters.Add("returnUrl", returnUrl);
             urlBuilder.AddQueryParameters(queryParameters);
             pageUrl = urlBuilder.ToString();
         }
         HttpContext.Current.Response.Redirect(pageUrl, false);
         return true;
     }
     return false;
 }
        private static string BuildInternalUrl(PageUrlData pageUrlData)
        {
            var cultureInfo = pageUrlData.LocalizationScope;
            var publicationScope = pageUrlData.PublicationScope;

            var result = new UrlBuilder("~/page(" + pageUrlData.PageId + ")");

            string pathInfo = string.Empty;

            if (publicationScope == PublicationScope.Unpublished)
            {
                pathInfo = UrlMarker_Unpublished;
            }

            if (!pageUrlData.PathInfo.IsNullOrEmpty())
            {
                pathInfo += pageUrlData.PathInfo;
            }
            result.PathInfo = pathInfo;


            result["cultureInfo"] = cultureInfo.ToString();

            if (pageUrlData.QueryParameters != null)
            {
                result.AddQueryParameters(pageUrlData.QueryParameters);
            }

            return result;
        }
        private static string BuildRenderUrl(PageUrlData pageUrlData)
        {
            var cultureInfo = pageUrlData.LocalizationScope;
            string legacyScopeName = GetLegacyPublicationScopeIdentifier(pageUrlData.PublicationScope);

            string basePath = UrlUtils.ResolvePublicUrl("Renderers/Page.aspx");
            var result = new UrlBuilder(basePath);

            result["pageId"] = pageUrlData.PageId.ToString();
            result["cultureInfo"] = cultureInfo.ToString();
            result["dataScope"] = legacyScopeName;

            result.PathInfo = pageUrlData.PathInfo;
            if (pageUrlData.QueryParameters != null)
            {
                result.AddQueryParameters(pageUrlData.QueryParameters);
            }

            return result;
        }
        private string BuildPublicUrl(PageUrlData pageUrlData, UrlSpace urlSpace)
        {
            var cultureInfo = pageUrlData.LocalizationScope;
            var publicationScope = pageUrlData.PublicationScope;

            var pageUrlPath = new StringBuilder();

            using (new DataScope(publicationScope, cultureInfo))
            {
                if (!BuildPageUrlPath(pageUrlData.PageId, cultureInfo, urlSpace, pageUrlPath))
                {
                    return null;
                }
            }

            if (publicationScope == PublicationScope.Unpublished)
            {
                AppendUrlPart(pageUrlPath, UrlMarker_Unpublished);
            }

            if (urlSpace.ForceRelativeUrls)
            {
                AppendUrlPart(pageUrlPath, UrlMarker_RelativeUrl);
            }

            if (!string.IsNullOrEmpty(UrlSuffix) 
                && pageUrlPath[pageUrlPath.Length - 1] != '/')
            {
                pageUrlPath.Append(UrlSuffix);
            }

            if (!string.IsNullOrEmpty(pageUrlData.PathInfo))
            {
                AppendPathInfo(pageUrlPath, pageUrlData.PathInfo);
            }


            string url = pageUrlPath.ToString();

            if (pageUrlData.QueryParameters != null)
            {
                var urlWithQuery = new UrlBuilder(url);
                urlWithQuery.AddQueryParameters(pageUrlData.QueryParameters);

                return urlWithQuery;
            }

            return url;
        }