【问题标题】:XAML Image Source does not work for https?XAML 图像源不适用于 https?
【发布时间】:2013-03-08 03:09:10
【问题描述】:

你好,一群很棒的人,

在我的 XAML 中,我想为图像的 Source 属性使用绝对 URI。

如果 URI 是“http”,它可以工作。如果 URI 是“https”,则不是。

为了备份并将其放在上下文中,我通过 REST API 连接到 JIRA,并且我正在反序列化给我一个 JIRA 问题的响应。该问题有一个问题类型,并且该问题类型有一个我要绑定的“iconUrl”属性。

我已经调试并验证了到目前为止一切都是正确的。我认为这是获得正确身份验证的问题,因此我对图像的请求不会被拒绝。

我的 JiraRestClient 构造函数(使用 RestSharp):

public JiraRestClient(string baseUrl, string username, string password)
{
    this.BaseUrl = baseUrl;
    this.ServerUrl = baseUrl.Substring(0, baseUrl.IndexOf("rest"));
    client = new RestClient();
    client.BaseUrl = baseUrl;
    client.Authenticator = new HttpBasicAuthenticator(username, password); //culprit??
}

我对客户端的使用:

public JiraIssue GetIssueByID(string issueKeyOrId)
{
    request = new RestRequest();
    request.Resource = "issue/" + issueKeyOrId;
    IRestResponse response = client.Execute(request);
    JavaScriptSerializer serializer = new JavaScriptSerializer();
    // Deserialize the response into a JiraIssue object
    JiraIssue issue = serializer.Deserialize<JiraIssue>(response.Content);
    ...
    return issue;
}

在我通过身份验证并创建我的 REST 客户端后,我只是想直接在 XAML 中提取问题类型的图像(在这里,我用绝对 URI 替换了绑定,这也不起作用):

...
<Image Height="16" Width="16" Source="https://..."/>
...

我错过了什么? HttpBasicAuthenticator 的东西? 提前致谢!

【问题讨论】:

    标签: c# xaml rest jira


    【解决方案1】:

    问题的根源在于我试图绑定的图像/图标实际上并不存在于 JIRA 服务器上;它们位于 Confluence 网站上,作为 wiki 页面的附件。因此,问题与 HTTPS 无关,更多的是与使用 Confluence 进行身份验证以下载图像有关。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-24
      • 1970-01-01
      • 2017-04-23
      相关资源
      最近更新 更多