Price: US$19.00

Pay securely at PayPal. On the confirmation page, click Continue to product download page to download this product immediately.

Having a PayPal account is optional; if you don't want to sign up, look for the link which says Don't have a PayPal account?

Friendly URL Writer

API Documentation

FriendlyUrlWriter.EmptyTextBehavior

Specifies the action to take when a URL converter receives a null or empty string, or a string containing only invalid characters.

NameDescription

Field

ThrowException

An argument exception will be thrown by the IUrlWriter.ToUrlString(System.String) method.

Field

ReturnString

The string specified by IUrlWriter.ReturnTextForEmptyStrings will be returned.

FriendlyUrlWriter.IUrlWriter

Rewrites strings as URL-friendly strings, for example converts the string "Look - it's great!" to "Look_-_its_great".

Properties

NameDescription

Property

EmptyTextBehavior

Gets or sets the action that this converter will take when a null or empty string is passed to IUrlWriter.ToUrlString(System.String), or when the string contains only invalid URL characters.

Property

ReturnTextForEmptyStrings

The text to use when IUrlWriter.EmptyTextBehavior is equal to EmptyTextBehavior.ReturnString and the text passed to IUrlWriter.ToUrlString(System.String) is null, empty, or contains only invalid characters. This value may be a null or empty string itself, and defaults to "Page".

Property

SpaceCharacter

The character to use for spaces. This character must be valid in a URL. The default value is an underscore ('_').

System.ArgumentException: The value specified is not a valid character for a URL.

Property

PreserveSlashes

Gets or sets a value indicating whether or not to preserve forward-slash ('/') characters when converting strings to URL strings. If true, then the returned string will include '/' characters; if false these characters will be removed. Set this to true when you want to convert relative URLs, preserving folder names. This is true by default.

Example: Consider passing the string "Photos/New Zealand/Roger's Peak" to the IUrlWriter.ToUrlString(System.String) method. When this property is set to true, the string returned will be "Photos/New_Zealand/Rogers_Peak". When set to false, the string returned will be "Photos_New_Zealand_Rogers_Peak".

Property

MaximumLength

Gets or sets the maximum number of characters that a string returned from IUrlWriter.ToUrlString(System.String) can be. In cases where the maximum length is exceeded, the string is truncated at the end. If a file extension was provided, then the extension will not be truncated. The default value for this property is 80 characters.

System.ArgumentException: The value specified is less than 10 or greater than 2000.

Methods

NameDescription

Method

ToUrlString (System.String text)

Converts a piece of text in any language with any formatting or punctuation characters into a human-readable URL which contains only valid characters.

Parameters

text:

Return Value

Returns a human-readable URL-encoded string which can be used as part of a URL.

Exceptions

System.ArgumentException: Thrown when IUrlWriter.EmptyTextBehavior is equal to EmptyTextBehavior.ReturnString and the text passed to IUrlWriter.ToUrlString(System.String) is null, empty, or contains only invalid characters.

FriendlyUrlWriter.UrlWriter

Rewrites strings as URL-friendly strings, for example converts the string "Look - it's great!" to "Look_-_its_great".

Properties

NameDescription

Property

Default

Gets an instance of the URL String Converter using default settings. The default settings can be changed using the properties on the returned object.

Property

EmptyTextBehavior

Gets or sets the action that this converter will take when a null or empty string is passed to UrlWriter.ToUrlString(System.String), or when the string contains only invalid URL characters.

Property

ReturnTextForEmptyStrings

The text to use when UrlWriter.EmptyTextBehavior is equal to EmptyTextBehavior.ReturnString and the text passed to UrlWriter.ToUrlString(System.String) is null, empty, or contains only invalid characters. This value may be a null or empty string itself, and defaults to "Page".

Property

SpaceCharacter

The character to use for spaces. This character must be valid in a URL. The default value is an underscore ('_').

System.ArgumentException: The value specified is not a valid character for a URL.

Property

PreserveSlashes

Gets or sets a value indicating whether or not to preserve forward-slash ('/') characters when converting strings to URL strings. If true, then the returned string will include '/' characters; if false these characters will be removed. Set this to true when you want to convert relative URLs, preserving folder names. This is true by default.

Example: Consider passing the string "Photos/New Zealand/Roger's Peak" to the UrlWriter.ToUrlString(System.String) method. When this property is set to true, the string returned will be "Photos/New_Zealand/Rogers_Peak". When set to false, the string returned will be "Photos_New_Zealand_Rogers_Peak".

Property

MaximumLength

Gets or sets the maximum number of characters that a string returned from UrlWriter.ToUrlString(System.String) can be. In cases where the maximum length is exceeded, the string is truncated at the end. If a file extension was provided, then the extension will not be truncated. The default value for this property is 80 characters.

System.ArgumentException: The value specified is less than 10 or greater than 2000.

Methods

NameDescription

Method

ToUrlString (System.String text)

Converts a piece of text in any language with any formatting or punctuation characters into a human-readable URL which contains only valid characters.

Parameters

text:

Return Value

Returns a human-readable URL-encoded string which can be used as part of a URL.

Exceptions

System.ArgumentException: Thrown when UrlWriter.EmptyTextBehavior is equal to EmptyTextBehavior.ReturnString and the text passed to UrlWriter.ToUrlString(System.String) is null, empty, or contains only invalid characters.