Sco*_*den 16 .net c# validation url uri
我正在尝试使用Uri.TryCreate方法验证Uri,当我使用无效字符串调用它时,该方法返回true.有什么想法吗?我的代码如下:
private void button1_Click(object sender, EventArgs e)
{
Uri tempValue;
if (Uri.TryCreate("NotAURL", UriKind.RelativeOrAbsolute, out tempValue))
{
MessageBox.Show("?");
}
}
Run Code Online (Sandbox Code Playgroud)
Mat*_*hen 23
这是一个有效的相对URL.无效URI的示例是:
"http://example.com<>"
Run Code Online (Sandbox Code Playgroud)
如果您只想允许绝对URI,请使用UriKind.Absolute.
然后该示例将无法解析.
| 归档时间: |
|
| 查看次数: |
14075 次 |
| 最近记录: |