gpt4 book ai didi

c# - 无法在路径中找到非法字符

转载 作者:行者123 更新时间:2023-11-30 20:44:41 28 4
gpt4 key购买 nike

我无法在

中找到非法字符

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

当我直接将它复制到 Chrome 时,该 URL 工作正常。知道问题出在哪里吗?

最佳答案

我认为问题是因为缺少协议(protocol)(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);

关于c# - 无法在路径中找到非法字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28978966/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com