【问题标题】:System.UriFormatException: Invalid URI: The Authority/Host could not be parsedSystem.UriFormatException:无效的 URI:无法解析授权/主机
【发布时间】:2018-06-13 14:01:52
【问题描述】:

Uri uri = new Uri(siteURL);

在哪里siteURL="https://abcdev.sharepoint.com/sites/TestDuplicate";

我得到了异常:

System.UriFormatException:无效的 URI:无法解析授权/主机

【问题讨论】:

  • 这本身应该没问题。一定有其他代码导致错误。
  • 这是我得到异常的行。

标签: asp.net exception uri


【解决方案1】:

上面的代码看起来是正确的。即使在即时窗口的运行时,它也能很好地工作。 你确定你不对字符串做任何操作吗?当我的主机格式不正确时,我遇到了类似的错误:

var requestString = string.Join('/', urlParts).Replace("//", "/");

它所做的是将 http:// 替换为 http://,这导致了异常。

【讨论】:

    猜你喜欢
    • 2011-02-18
    • 1970-01-01
    • 1970-01-01
    • 2014-02-25
    • 2019-08-29
    • 2011-05-11
    • 2016-01-28
    • 2023-03-09
    • 1970-01-01
    相关资源
    最近更新 更多