对于任何字符串值,Uri.TryCreate都返回true?

我正在尝试使用Uri.TryCreate方法validationUri,当我使用无效字符串调用它时,该方法返回true。 有什么想法吗? 我的代码如下:

private void button1_Click(object sender, EventArgs e) { Uri tempValue; if (Uri.TryCreate("NotAURL", UriKind.RelativeOrAbsolute, out tempValue)) { MessageBox.Show("?"); } } 

这是一个有效的相对URL。 无效URI的示例是:

 "http://example.com<>" 

如果您只想允许绝对URI,请使用UriKind.Absolute

然后该示例将无法解析。