PDA

View Full Version : Preloading and Displaying an Image



bouncer
January 3rd, 2009, 09:20 PM
Hi Kirupa,

I'm one of the follower of your articles. Based on your article I tried preloading and displaying images. It works fine with this url :
http://www.community-credit.com/images/developers/KarlShifflettMug.jpg

but whenever I try to set this Url :

http://www.beacosta.com/uploaded_images/BeaBlackAndWhite.jpg

I'm getting this exception : An exception occurred during the operation, making the result invalid. Check InnerException for exception details.

I've placed the clientaccesspolicy.xml at the root of the web site.

Would you please tell what's going wrong here ?

kirupa
January 3rd, 2009, 09:38 PM
Hi Bouncer!
The clientaccesspolicy.xml file needs to be at the root of the web site you are retrieving the images from. The community-credit site has a very open access policy: http://www.community-credit.com/clientaccesspolicy.xml It accepts requests from any domain.

Beatriz's site does not have a clientaccesspolicy XML file specified, so by default (I believe) only requests made from her domain will work. That means that your request will unfortunately return an error.

The way to work around this is to load the image without using the WebClient class and related classes that make a web request. The other solution is to ask beatriz nicely to include an access policy file for you :)

bouncer
January 3rd, 2009, 10:16 PM
Thanks for your reply Kirupa. I'm not going to ask Beatriz. I won't use WebClient.

samuelt
February 24th, 2009, 11:56 AM
I tried using this tutorial using file system (no website created) and I'm still getting the same exception.

Any ideas why?

Screenshot attached:

kirupa
February 24th, 2009, 09:38 PM
Sam - you will need a web site project in order to have all of this work. The reason is that the WebClient methods require a web server to be running. The ASP.net development server that runs as part of previewing a Web Site project is sufficient :)