WPF add header to Image with URL pettitions [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
Image source URI requiring authorization
3 answers
Add header to all* HTTP requests on a machine
1 answer
first of all sorry for my english.
Recently I added some security in the backend of my project, and now I need to send a validation code(apiKey) inside the headers to retrieve the images.
I have a problem with ALL images in my project that I had attached in my UI.
For example, before I had:
<Image Height="90" Source="{Binding Video.Thumbnail}"/>
Now I need to change my code to create a CUSTOM petition add the apiKey in the header:
<Image Height="90">
<Image.Source>
<MultiBinding Converter="{local:GetFrameConverter}">
<Binding Path="ApiKey" IsAsync="True" />
<Binding Path="Video.Thumbnail" IsAsync="True" />
</MultiBinding>
</Image.Source>
</Image>
It works fine, but now I have a heavy problem of performance, because it download always the image no cache, and it seems that for example in a ListView is not Async, and it reloads when scroll is triggered. Furthermore sometimes when I'm requesting a lot of images at the same time I recieve corrupted images, I don't know why.
The behaivour when I assign via "the native" Source with URL works perfect.
So, Has a way to can define custom headers for the requests that goes to http/https resources in WPF by default?
And if is not a way by default, has a way to do it in the xaml tag (or in code-behind)?
NOTE: I already saw the question (Image source URI requiring authorization) I'm not fan of this solution I prefer use native way.. but it seems that is not possible.. I only want to be sure that is not possible. If not, How can I create this server proxy inside of my app?? Or I need tu run another server dedicated?
NOTE2: I'm using HTTPS
Thanks in advance!
wpf
marked as duplicate by Clemens
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 at 12:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
Image source URI requiring authorization
3 answers
Add header to all* HTTP requests on a machine
1 answer
first of all sorry for my english.
Recently I added some security in the backend of my project, and now I need to send a validation code(apiKey) inside the headers to retrieve the images.
I have a problem with ALL images in my project that I had attached in my UI.
For example, before I had:
<Image Height="90" Source="{Binding Video.Thumbnail}"/>
Now I need to change my code to create a CUSTOM petition add the apiKey in the header:
<Image Height="90">
<Image.Source>
<MultiBinding Converter="{local:GetFrameConverter}">
<Binding Path="ApiKey" IsAsync="True" />
<Binding Path="Video.Thumbnail" IsAsync="True" />
</MultiBinding>
</Image.Source>
</Image>
It works fine, but now I have a heavy problem of performance, because it download always the image no cache, and it seems that for example in a ListView is not Async, and it reloads when scroll is triggered. Furthermore sometimes when I'm requesting a lot of images at the same time I recieve corrupted images, I don't know why.
The behaivour when I assign via "the native" Source with URL works perfect.
So, Has a way to can define custom headers for the requests that goes to http/https resources in WPF by default?
And if is not a way by default, has a way to do it in the xaml tag (or in code-behind)?
NOTE: I already saw the question (Image source URI requiring authorization) I'm not fan of this solution I prefer use native way.. but it seems that is not possible.. I only want to be sure that is not possible. If not, How can I create this server proxy inside of my app?? Or I need tu run another server dedicated?
NOTE2: I'm using HTTPS
Thanks in advance!
wpf
marked as duplicate by Clemens
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 at 12:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Your GetFrameConverter may explicitly cache images, e.g. by using ObjectCache. In order to also load images asynchronously you should move from a converter to another view model property, which would be bound asynchronously and return a frozen BitmapSource. Bindings do not support asynchronous converter calls, only the property getter may be called asynchronously.
– Clemens
Nov 19 at 12:15
This is not my question.. If I don't have more ways to work, I will check how to change all of my code to can run better with my own pettition... But first I want to change the less things as possible in the code. but thanks..
– Riqui Pijoan Gassó
Nov 19 at 12:17
@Clemens Thanks a lot for the #duplicate reference. I saw before .. but I'm surprised for that is impossible in native.. now I edited my question because I still don't know how to implement the answer that is marked as a solution. I'm very begginer with wpf and I understant the logic of the solution.. but i don't know how to start to implement a proxy inside my code. You know how it works, or only knows that exists that solution? Thanks!
– Riqui Pijoan Gassó
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Image source URI requiring authorization
3 answers
Add header to all* HTTP requests on a machine
1 answer
first of all sorry for my english.
Recently I added some security in the backend of my project, and now I need to send a validation code(apiKey) inside the headers to retrieve the images.
I have a problem with ALL images in my project that I had attached in my UI.
For example, before I had:
<Image Height="90" Source="{Binding Video.Thumbnail}"/>
Now I need to change my code to create a CUSTOM petition add the apiKey in the header:
<Image Height="90">
<Image.Source>
<MultiBinding Converter="{local:GetFrameConverter}">
<Binding Path="ApiKey" IsAsync="True" />
<Binding Path="Video.Thumbnail" IsAsync="True" />
</MultiBinding>
</Image.Source>
</Image>
It works fine, but now I have a heavy problem of performance, because it download always the image no cache, and it seems that for example in a ListView is not Async, and it reloads when scroll is triggered. Furthermore sometimes when I'm requesting a lot of images at the same time I recieve corrupted images, I don't know why.
The behaivour when I assign via "the native" Source with URL works perfect.
So, Has a way to can define custom headers for the requests that goes to http/https resources in WPF by default?
And if is not a way by default, has a way to do it in the xaml tag (or in code-behind)?
NOTE: I already saw the question (Image source URI requiring authorization) I'm not fan of this solution I prefer use native way.. but it seems that is not possible.. I only want to be sure that is not possible. If not, How can I create this server proxy inside of my app?? Or I need tu run another server dedicated?
NOTE2: I'm using HTTPS
Thanks in advance!
wpf
This question already has an answer here:
Image source URI requiring authorization
3 answers
Add header to all* HTTP requests on a machine
1 answer
first of all sorry for my english.
Recently I added some security in the backend of my project, and now I need to send a validation code(apiKey) inside the headers to retrieve the images.
I have a problem with ALL images in my project that I had attached in my UI.
For example, before I had:
<Image Height="90" Source="{Binding Video.Thumbnail}"/>
Now I need to change my code to create a CUSTOM petition add the apiKey in the header:
<Image Height="90">
<Image.Source>
<MultiBinding Converter="{local:GetFrameConverter}">
<Binding Path="ApiKey" IsAsync="True" />
<Binding Path="Video.Thumbnail" IsAsync="True" />
</MultiBinding>
</Image.Source>
</Image>
It works fine, but now I have a heavy problem of performance, because it download always the image no cache, and it seems that for example in a ListView is not Async, and it reloads when scroll is triggered. Furthermore sometimes when I'm requesting a lot of images at the same time I recieve corrupted images, I don't know why.
The behaivour when I assign via "the native" Source with URL works perfect.
So, Has a way to can define custom headers for the requests that goes to http/https resources in WPF by default?
And if is not a way by default, has a way to do it in the xaml tag (or in code-behind)?
NOTE: I already saw the question (Image source URI requiring authorization) I'm not fan of this solution I prefer use native way.. but it seems that is not possible.. I only want to be sure that is not possible. If not, How can I create this server proxy inside of my app?? Or I need tu run another server dedicated?
NOTE2: I'm using HTTPS
Thanks in advance!
This question already has an answer here:
Image source URI requiring authorization
3 answers
Add header to all* HTTP requests on a machine
1 answer
wpf
wpf
edited yesterday
asked Nov 19 at 12:00
Riqui Pijoan Gassó
15
15
marked as duplicate by Clemens
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 at 12:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Clemens
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 at 12:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Your GetFrameConverter may explicitly cache images, e.g. by using ObjectCache. In order to also load images asynchronously you should move from a converter to another view model property, which would be bound asynchronously and return a frozen BitmapSource. Bindings do not support asynchronous converter calls, only the property getter may be called asynchronously.
– Clemens
Nov 19 at 12:15
This is not my question.. If I don't have more ways to work, I will check how to change all of my code to can run better with my own pettition... But first I want to change the less things as possible in the code. but thanks..
– Riqui Pijoan Gassó
Nov 19 at 12:17
@Clemens Thanks a lot for the #duplicate reference. I saw before .. but I'm surprised for that is impossible in native.. now I edited my question because I still don't know how to implement the answer that is marked as a solution. I'm very begginer with wpf and I understant the logic of the solution.. but i don't know how to start to implement a proxy inside my code. You know how it works, or only knows that exists that solution? Thanks!
– Riqui Pijoan Gassó
2 days ago
add a comment |
Your GetFrameConverter may explicitly cache images, e.g. by using ObjectCache. In order to also load images asynchronously you should move from a converter to another view model property, which would be bound asynchronously and return a frozen BitmapSource. Bindings do not support asynchronous converter calls, only the property getter may be called asynchronously.
– Clemens
Nov 19 at 12:15
This is not my question.. If I don't have more ways to work, I will check how to change all of my code to can run better with my own pettition... But first I want to change the less things as possible in the code. but thanks..
– Riqui Pijoan Gassó
Nov 19 at 12:17
@Clemens Thanks a lot for the #duplicate reference. I saw before .. but I'm surprised for that is impossible in native.. now I edited my question because I still don't know how to implement the answer that is marked as a solution. I'm very begginer with wpf and I understant the logic of the solution.. but i don't know how to start to implement a proxy inside my code. You know how it works, or only knows that exists that solution? Thanks!
– Riqui Pijoan Gassó
2 days ago
Your GetFrameConverter may explicitly cache images, e.g. by using ObjectCache. In order to also load images asynchronously you should move from a converter to another view model property, which would be bound asynchronously and return a frozen BitmapSource. Bindings do not support asynchronous converter calls, only the property getter may be called asynchronously.
– Clemens
Nov 19 at 12:15
Your GetFrameConverter may explicitly cache images, e.g. by using ObjectCache. In order to also load images asynchronously you should move from a converter to another view model property, which would be bound asynchronously and return a frozen BitmapSource. Bindings do not support asynchronous converter calls, only the property getter may be called asynchronously.
– Clemens
Nov 19 at 12:15
This is not my question.. If I don't have more ways to work, I will check how to change all of my code to can run better with my own pettition... But first I want to change the less things as possible in the code. but thanks..
– Riqui Pijoan Gassó
Nov 19 at 12:17
This is not my question.. If I don't have more ways to work, I will check how to change all of my code to can run better with my own pettition... But first I want to change the less things as possible in the code. but thanks..
– Riqui Pijoan Gassó
Nov 19 at 12:17
@Clemens Thanks a lot for the #duplicate reference. I saw before .. but I'm surprised for that is impossible in native.. now I edited my question because I still don't know how to implement the answer that is marked as a solution. I'm very begginer with wpf and I understant the logic of the solution.. but i don't know how to start to implement a proxy inside my code. You know how it works, or only knows that exists that solution? Thanks!
– Riqui Pijoan Gassó
2 days ago
@Clemens Thanks a lot for the #duplicate reference. I saw before .. but I'm surprised for that is impossible in native.. now I edited my question because I still don't know how to implement the answer that is marked as a solution. I'm very begginer with wpf and I understant the logic of the solution.. but i don't know how to start to implement a proxy inside my code. You know how it works, or only knows that exists that solution? Thanks!
– Riqui Pijoan Gassó
2 days ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your GetFrameConverter may explicitly cache images, e.g. by using ObjectCache. In order to also load images asynchronously you should move from a converter to another view model property, which would be bound asynchronously and return a frozen BitmapSource. Bindings do not support asynchronous converter calls, only the property getter may be called asynchronously.
– Clemens
Nov 19 at 12:15
This is not my question.. If I don't have more ways to work, I will check how to change all of my code to can run better with my own pettition... But first I want to change the less things as possible in the code. but thanks..
– Riqui Pijoan Gassó
Nov 19 at 12:17
@Clemens Thanks a lot for the #duplicate reference. I saw before .. but I'm surprised for that is impossible in native.. now I edited my question because I still don't know how to implement the answer that is marked as a solution. I'm very begginer with wpf and I understant the logic of the solution.. but i don't know how to start to implement a proxy inside my code. You know how it works, or only knows that exists that solution? Thanks!
– Riqui Pijoan Gassó
2 days ago