HttpUtility class
SharePoint Online
Provides access to methods used to encode and decode strings during the processing of Web requests.
Namespace: Microsoft.SharePoint.Client.Utilities
Assembly: Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
This code example encodes the URL of the All Tasks View of the specified site.
using System; using Microsoft.SharePoint.Client; namespace Microsoft.SDK.SharePointFoundation.Samples { class HttpUtilityExample { static void Main() { string siteUrl = "http://MyServer/sites/MySiteCollection"; ClientContext clientContext = new ClientContext(siteUrl); Web site = clientContext.Web; List targetList = site.Lists.GetByTitle("Tasks"); View targetView = targetList.Views.GetByTitle("All Tasks"); clientContext.Load(targetView); clientContext.ExecuteQuery(); String relativeUrl = targetView.ServerRelativeUrl; String encodedUrl = Microsoft.SharePoint.Client.Utilities.HttpUtility.EcmaScriptStringLiteralEncode(relativeUrl); Console.WriteLine("Encoded All Tasks View URL: {0}", encodedUrl); } } }
Show: