无法在路径中找到非法字符

Unable to find illegal Characters in Path

我无法在

中找到非法字符

www.rightmove.co.uk/propertyMedia/redirect.html?propertyId=47772832&contentId=778055923&index=0

这是我从调试器中获取的 URL。

我在WebClient

这个方法中使用了上面的URL
string document = w.DownloadString(url);

这会引发异常:

Argument Exception :Illegal Characters in path

URL 直接复制到 Chrome 就可以正常工作了。知道问题出在哪里吗?

我认为问题是因为缺少协议(httphttps

使用 Uri.IsWellFormedUriString 检查 Uri 是否有效。

错误:

Uri.IsWellFormedUriString("www.rightmove.co.uk/propertyMedia/redirect.html?propertyId=47772832&contentId=778055923&index=0",UriKind.Absolute);

正确:

Uri.IsWellFormedUriString("http://www.rightmove.co.uk/propertyMedia/redirect.html?propertyId=47772832&contentId=778055923&index=0",UriKind.Absolute);