简体   繁体   中英

XAML Image Source does not work for https?

Hi community of awesome people,

In my XAML I want to use an absolute URI for an Image's Source property.

If the URI is "http" it works. If the URI is "https" it doesn't.

To back up and put this in context, I'm connecting to JIRA via the REST API, and I'm deserializing the response which gives me a JIRA issue. The issue has an issue type, and the issue type has an "iconUrl" property that I'm binding to.

I have debugged and verified that all is correct up to that point. I believe this is an issue with getting the correct authentication in place so my request for the image doesn't get rejected.

My JiraRestClient constructor (using 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??
}

My use of the client:

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;
}

After I've authenticated and create my REST client, I'm just trying to pull in the image of an issuetype in the XAML directly (here, I've replaced the binding with an absolute URI, which is also not working):

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

What am I missing? Something with the HttpBasicAuthenticator? Thanks in advance!

The root of the problem is that the images/icons I was trying to bind to don't actually exist on the JIRA server; they're on a Confluence website as attachments to a wiki page. So, the problem has nothing to do with HTTPS and more to do with authenticating with Confluence in order to download the image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM