Invalid Uri:Uri 方案无效

发布于 12-07 22:13 字数 157 浏览 1 评论 0原文

我正在尝试通过 HttpWebRequest 建立连接。我正在从文本文件读取 url 链接。 但是,我收到“System.UriFormatException”错误。

我尝试在文本文件中的 url 链接前面添加 http:// 。但结果是一样的。

有什么解决办法吗?

I am trying to make a connection via HttpWebRequest. I am reading url links from a text file.
However, I am getting 'System.UriFormatException' error.

I have tried to add http:// in front of the url links in my text file. But the result is the same.

What can be the solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

远昼2024-12-14 22:13:26

如果错误仅在从文件读取值时发生,而不是在直接分配给 string 变量时发生,那么我猜测读取了额外的字符(引号、转义字符、回车符)返回/换行等)。

尝试将第一个值读入字符串,然后将其与您期望的显式字符串值进行比较。之后任何差异都应该是显而易见的。

If the error only occurs when reading the values from a file, but not when assigned directly to a string variable, then I'm guessing that there are extra characters being read (quotes, escaped characters, carriage-return/line feeds, etc).

Try reading the first value into a string, and then comparing that to what you expect in the explicit string value. Any differences should be obvious after that.

泪是无色的血2024-12-14 22:13:26

如果没有看到代码,就不可能知道你想要做什么。但您可以首先查看消息 UriFormatException 类的属性。 Message 是一个解释异常原因的字符串。

Without seeing code it's impossible to tell what you're trying to do. But you can start by looking at the Message property of the UriFormatException class. Message is a string that explains the reason for the exception.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文