Uri.IsWellFormedOriginalString Uri.IsWellFormedOriginalString Uri.IsWellFormedOriginalString Uri.IsWellFormedOriginalString Method

定义

指示用于构造此 Uri 的字符串是否格式良好,以及它是否不需要进一步转义。Indicates whether the string used to construct this Uri was well-formed and is not required to be further escaped.

public:
 bool IsWellFormedOriginalString();
public bool IsWellFormedOriginalString ();
member this.IsWellFormedOriginalString : unit -> bool
Public Function IsWellFormedOriginalString () As Boolean

返回

如果该字符串格式正确,则为 true;否则为 falsetrue if the string was well-formed; otherwise, false.

注解

默认情况下是根据 RFC 2396 和 RFC 2732 格式正确,认为该字符串。The string is considered to be well-formed in accordance with RFC 2396 and RFC 2732 by default. 如果启用了国际资源标识符 (Iri) 或国际化域名 (IDN) 分析,该字符串被视为可根据 RFC 3986 和 RFC 3987 格式正确If International Resource Identifiers (IRIs) or Internationalized Domain Name (IDN) parsing is enabled, the string is considered to be well-formed in accordance with RFC 3986 and RFC 3987

将认为该字符串格式很差,并导致此方法返回 false,如果发生以下情况。The string is considered poorly formed, causing the method to return false, if any of the following conditions occur.

ErrorError 示例Example
未正确转义字符串。The string is not correctly escaped. http://www.contoso.com/path???/file 名称http://www.contoso.com/path???/file name
字符串是绝对Uri,表示隐式文件UriThe string is an absolute Uri that represents an implicit file Uri. c:\\directory\filenamec:\\directory\filename
该字符串是缺少斜杠之前路径的绝对 URI。The string is an absolute URI that is missing a slash before the path. file://c:/directory/filenamefile://c:/directory/filename
字符串包含非转义反斜杠,即使它们被视为正斜杠。The string contains unescaped backslashes even if they are treated as forward slashes. http:\\host/path/filehttp:\\host/path/file
该字符串表示层次结构的绝对Uri,并且不包含"://"。The string represents a hierarchical absolute Uri and does not contain "://". www.contoso.com/path/filewww.contoso.com/path/file
分析器Uri.Scheme指示原始字符串不是格式正确。The parser for the Uri.Scheme indicates that the original string was not well-formed. 此示例依赖于 URI 的方案。The example depends on the scheme of the URI.

默认情况下,该字符串用于构造此Uri被视为格式正确,符合 RFC 2396 和 RFC 2732。By default, the string used to construct this Uri are considered well-formed in accordance with RFC 2396 and RFC 2732.

当启用时国际资源标识符 (IRI) 和国际化域名 (IDN) 支持,用于构造此字符串Uri被视为格式正确,符合 RFC 3986 和 RFC 3987。When International Resource Identifier (IRI) and Internationalized Domain Name (IDN) support are enabled, the string used to construct this Uri are considered well-formed in accordance with RFC 3986 and RFC 3987. 用于支持 IRI Punycode 名称只能包含 ASCII 字符,并且始终以 xn--前缀开头。Punycode names used to support IRI contain only ASCII characters and always start with the xn-- prefix.

IRI 支持的详细信息,请参阅备注部分Uri类。For more information on IRI support, see the Remarks section for the Uri class.

适用于

另请参阅