Uri.IsWellFormedUriString Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Indicates whether the string is well-formed by attempting to construct a Uri with the string and ensures that the string does not require further escaping.
Namespace: System
Assembly: System (in System.dll)
Syntax
'Declaration
Public Shared Function IsWellFormedUriString ( _
uriString As String, _
uriKind As UriKind _
) As Boolean
public static bool IsWellFormedUriString(
string uriString,
UriKind uriKind
)
Parameters
- uriString
Type: System.String
A Uri represented as a string.
- uriKind
Type: System.UriKind
The type of the URI in uriString parameter.
Return Value
Type: System.Boolean
A Boolean value that is true if the string was well-formed in accordance with RFC 3986; else false.
Remarks
The string is considered poorly formed, causing the method to return false, if any of the following conditions occur
Error |
Example |
---|---|
The string is not correctly escaped. |
|
The string is an absolute Uri that represents an implicit file Uri. |
c:\\directory\filename |
The string is an absolute URI that is missing a slash before the path. |
file://c:/directory/filename |
The string contains unescaped backslashes even if they will be treated as forward slashes |
http:\\host/path/file |
The string represents a hierarchical absolute Uri and does not contain "://" |
www.contoso.com/path/file |
The parser for the Scheme indicates that the original string was not well-formed. |
The example depends on the scheme of the URI. |
For more information, see RFC 2396, RFC 2732, and RFC 3986 available at http://www.ietf.org.
A uriString can be poorly formed and can still be used to construct a Uri instance. The Silverlight runtime will try to correct some minor issues with a poorly-formed string when the string is passed to one of the constructors for Uri.
The Uri constructors allow a Silverlight application to create a Uri instance for many schemes as described in the Scheme property. However, only Uri instances for the UriSchemeHttp or UriSchemeHttps schemes are supported by the WebClient and HTTP classes in the System.Net namespace.
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.