Image source URI requiring authorization

后端 未结 3 1449
陌清茗
陌清茗 2021-01-26 10:57

On my WPF Window I have an Image whose UriSource is set to the URL of some image on the internet.


    

        
3条回答
  •  再見小時候
    2021-01-26 11:22

    i know this is an old thread but i wanted to follow up with the solution i found.

    .net has a cool feature to let you override it's core with your own methods on a system or application level. this can be done for the WebRequest.Create method

    see http://msdn.microsoft.com/en-us/library/bc0fhzk5.aspx

    this post is a full example including IWebRequestCreate so you don't get stuck in recursion.

    Add header to all* HTTP requests on a machine

    after all this, everything in your application scope will be forced to use your create method.

    NOTE: before adding your auth header, make sure you are on the right domain so you don't give out your auth to other places :)

提交回复
热议问题