XAML图像源不能用于https

本文关键字:用于 https 不能 图像 XAML | 更新日期: 2023-09-27 18:02:39

大家好,

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

如果URI是"http",它可以工作。如果URI是"https",则不会。

为了备份并把它放在上下文中,我通过REST API连接到JIRA,并且我正在反序列化给我JIRA问题的响应。issue有一个issue类型,issue类型有一个我要绑定的"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?提前感谢!

XAML图像源不能用于https

问题的根源是我试图绑定的图像/图标实际上不存在于JIRA服务器上;它们作为维基页面的附件出现在Confluence网站上。所以,这个问题与HTTPS无关,更多的是与Confluence的身份验证有关,以便下载图像。