Sitecore 5.1.1 API

MainUtil.EncodePath Method 

Encodes an item path.

[Visual Basic]
Public Shared Function EncodePath( _
   ByVal path As String, _
   ByVal separator As Char _
) As String
[C#]
public static string EncodePath(
   string path,
   char separator
);

Parameters

path
An item path.
separator
The separator used between elements of the path

Return Value

The encoded path.

Remarks

It can be necessary to encode item names to ensure working friendly URLs. For instance the item name "Bruun & Rasmussen" contains the character "&" which is URL automatically escaped by most browsers.

The encoding is configured in the web.config section <encodeNameReplacements>.

Example

  string encodedPath = MainUtil.EncodePath("/home/Bruun & Rasmussen"); // "/home/Bruun ,-a-, Rasmussen"

See Also

MainUtil Class | Sitecore Namespace | DecodeName