简体   繁体   English

提取图像,未经授权的访问异常错误

[英]fetching image , Unauthorized access exception error

I am fetching json data in which there is a link to again fetch an image 我正在获取json数据,其中有一个链接可以再次获取图像

For example: 例如:

{"status":"403","message":"Not Authorized","image":"http:\/\/abc.com\/images\/1.jpg"}

status, message n image are retrieved perfectly fine as i displayed there value in a text box. 状态,由于我在文本框中显示了值,因此可以很好地检索消息n图像。

Further I wanted to display image so I do: 此外,我想显示图像,所以我这样做:

public string link = ClassName.variableName;

link now holds the value http//abc.com/images/1.jpg . link现在拥有值http//abc.com/images/1.jpg I displayed its value in text box and its fine. 我在文本框中显示了它的值,并且很好。 So I moved further: 所以我进一步走了:

BitMapImage MyImage = new BitMapImage( new Uri (link, UriKind.RelativeOrAbsolute));

image1.source = MyImage;

But when I run it shows error "UnAuthorized access exception unhandled ". 但是,当我运行它时,会显示错误“未处理未授权的访问异常”。 To cross check I opened a new project and instead of fetching the data, I directly provided a link into the image source and the image was displayed. 为了进行交叉检查,我打开了一个新项目,而不是获取数据,而是直接提供了指向图像源的链接,并显示了图像。

BitMapImage MyImage = new BitMapImage( new Uri ("http//abc.com/images/1.jpg", UriKind.RelativeOrAbsolute));

image1.source = MyImage;

Here it works fine. 在这里工作正常。 Image is displayed. 显示图像。

我没有使用Deployment.Current.Dispatcher.BeginInvoke(()=>现在工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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