當前位置: 首頁>>代碼示例>>C#>>正文


C# Url.AppendQuery方法代碼示例

本文整理匯總了C#中N2.Web.Url.AppendQuery方法的典型用法代碼示例。如果您正苦於以下問題:C# Url.AppendQuery方法的具體用法?C# Url.AppendQuery怎麽用?C# Url.AppendQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在N2.Web.Url的用法示例。


在下文中一共展示了Url.AppendQuery方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerateCategoryLink

        public string GenerateCategoryLink(long? categoryId, bool? forceListPage, out object matchingCategoryPage)
        {
            //~~  a cheap and nasty chaos monkey
            //if (DateTime.Now.Minute % 2 == 1)
            //    throw new Exception("chaos happened " + categoryId);
            //~~

            string ret;
            var cacheKey = string.Format("{0} {1} {2} {3} {4}",
                WebSession.Current.SiteId, WebSession.Current.LanguageCode, "CategoryLink", categoryId, forceListPage);
            if (!_urlCache.TryGet(cacheKey, out ret))
            {
                var catPages = CmsFinder.FindDescendentsOrFallbackOfCurrentPageLanguageRoot<CatalogPage>();

                if (catPages.All(cps => cps.CategoryID.Length != 0))
                {
                    // find a category page from the root level that has no category ID
                    var defaultCatPage = CmsFinder.FindAllNonSiteDescendentsOfRoot<CatalogPage>()
                             .LastOrDefault(cps => cps.CategoryID.Length == 0);

                    if (defaultCatPage != null)
                        catPages.Add(defaultCatPage);
                }

                CatalogPage cp;

                if (forceListPage.HasValue && forceListPage.Value)
                    cp = catPages.LastOrDefault(catalogPage => catalogPage.CategoryID.Length == 0);
                else
                    cp = catPages.FirstOrDefault(catalogPage => catalogPage.CategoryID.Equals(categoryId.ToString(), StringComparison.InvariantCultureIgnoreCase)) ??
                             catPages.LastOrDefault(catalogPage => catalogPage.CategoryID.Length == 0);

                if (cp == null)
                    ret = null;
                else
                {
                    // If the category page came from the root, append it's name and parameters to the current page's url
                    var url = new Url(GetNormalizedPageUrl(cp));

                    if (string.IsNullOrEmpty(cp.CategoryID) && categoryId != null)
                        url = url.Append(categoryId.Value.ToString(CultureInfo.InvariantCulture));

                    if (forceListPage.HasValue && forceListPage.Value && string.IsNullOrEmpty(cp.CategoryID))
                        url = url.AppendQuery("list=true");

                    ret = url.ToString();
                }

                AddCache(cacheKey, ret, cp);
            }

            _itemCache.TryGet(cacheKey, out matchingCategoryPage);

            return ret;
        }
開發者ID:grbbod,項目名稱:drconnect-jungo,代碼行數:55,代碼來源:LinkGenerator.cs

示例2: SelectedUrl

 public string SelectedUrl(Url baseUrl, ContentItem selected = null)
 {
     return baseUrl.AppendQuery(SelectedQueryKey, (selected ?? SelectedItem).Path).ResolveTokens();
 }
開發者ID:brianmatic,項目名稱:n2cms,代碼行數:4,代碼來源:SelectionUtility.cs

示例3: securityEnforcer_AuthorizationFailed

		void securityEnforcer_AuthorizationFailed(object sender, CancellableItemEventArgs e)
		{
			var url = new Url("{ManagementUrl}/Login.aspx").ResolveTokens();
			url.AppendQuery("returnUrl", _context.Url.LocalUrl);
			_context.HttpContext.Response.Redirect(url);
		}
開發者ID:grbbod,項目名稱:drconnect-jungo,代碼行數:6,代碼來源:PermissionDeniedHandler.cs


注:本文中的N2.Web.Url.AppendQuery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。