HttpUtility class

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)

public class HttpUtility

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");


            String relativeUrl = targetView.ServerRelativeUrl;
            String encodedUrl = Microsoft.SharePoint.Client.Utilities.HttpUtility.EcmaScriptStringLiteralEncode(relativeUrl);
            Console.WriteLine("Encoded All Tasks View URL: {0}", encodedUrl);


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.