本文整理汇总了C#中Url.AppendQuery方法的典型用法代码示例。如果您正苦于以下问题:C# Url.AppendQuery方法的具体用法?C# Url.AppendQuery怎么用?C# Url.AppendQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url.AppendQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEditNewPageUrl
/// <summary>Gets the url to edit page creating new items.</summary>
/// <param name="selected">The selected item.</param>
/// <param name="definition">The type of item to edit.</param>
/// <param name="zoneName">The zone to add the item to.</param>
/// <param name="position">The position relative to the selected item to add the item.</param>
/// <returns>The url to the edit page.</returns>
public string GetEditNewPageUrl(ContentItem selected, ContentType definition, string zoneName, CreationPosition position)
{
if (selected == null) throw new ArgumentNullException("selected");
if (definition == null) throw new ArgumentNullException("definition");
ContentItem parent = (position != CreationPosition.Below) ? selected.Parent : selected;
if (selected == null)
throw new ZeusException("Cannot insert item before or after the root page.");
Url url = new Url(EditItemUrl);
url = url.AppendQuery("selected", parent.Path);
url = url.AppendQuery("discriminator", definition.Discriminator);
url = url.AppendQuery("zoneName", zoneName);
switch (position)
{
case CreationPosition.Before:
url = url.AppendQuery("before", selected.Path);
break;
case CreationPosition.After:
url = url.AppendQuery("after", selected.Path);
break;
}
return url.ToString();
}
示例2: FormatSelectedUrl
private static string FormatSelectedUrl(ContentItem selectedItem, string path)
{
Url url = new Url(path);
if (selectedItem != null)
url = url.AppendQuery("selected=" + selectedItem.Path);
return url.ToString();
}
示例3: BuildUrlInternal
protected string BuildUrlInternal(ContentItem item, string languageCode, out ContentItem startPage)
{
startPage = null;
ContentItem current = item;
Url url = new Url("/");
// Walk the item's parent items to compute it's url
do
{
if (IsStartPage(current))
{
startPage = current;
if (item.VersionOf != null)
url = url.AppendQuery(PathData.PageQueryKey, item.ID);
// Prepend language identifier, if this is not the default language.
if (_languageManager.Enabled && !LanguageSelection.IsHostLanguageMatch(ContentLanguage.PreferredCulture.Name))
{
if (LanguageSelection.GetHostFromLanguage(ContentLanguage.PreferredCulture.Name) != _webContext.LocalUrl.Authority)
url = url.SetAuthority(LanguageSelection.GetHostFromLanguage(ContentLanguage.PreferredCulture.Name));
else if (!string.IsNullOrEmpty(languageCode))
url = url.PrependSegment(languageCode, true);
}
// we've reached the start page so we're done here
return VirtualPathUtility.ToAbsolute("~" + url.PathAndQuery);
}
url = url.PrependSegment(current.Name, current.Extension);
current = current.GetParent(languageCode);
} while (current != null);
// If we didn't find the start page, it means the specified
// item is not part of the current site.
return "/?" + PathData.PageQueryKey + "=" + item.ID;
//return item.FindPath(PathData.DefaultAction).RewrittenUrl;
}