This project has moved and is read-only. For the latest updates, please go here.

FlickR Api in Medium Trust Hosting Environtment

Topics: Developer Forum
Jan 12, 2007 at 5:00 AM

Excellent API!! However I'm wondering if you can help me get around this error:

Unable to read default cache location. Please cacheLocation in configuration file or set manually in code

So i set:

Flickr.CacheDisabled = True;

Now I get:

Request for the permission of type 'System.Net.WebPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

In my web.config I have:

<trust level="Medium"/>

because my ISP's machine.config has this setting...

Jan 12, 2007 at 4:01 PM
Its possible that your Hosting Provider doesn't support your code calling outside web sites. Check with your Hosting Provider Support team.
Jan 13, 2007 at 12:18 AM
..this is running locally on my own machine
Jan 15, 2007 at 3:49 PM
Ah yes, I see...

Well as it turns out 'full' Medium Trust doesn't support any calls to outside URLs, so if you ISP is using full Medium trust then you're out of luck - However if they are using a modified Medium trust then you might be in luck.

In all other aspects though the Flickr API does work in medium trust...
Dec 20, 2007 at 5:03 PM
i also have this kind of problem, i hope you can help me guys. my dev server is running on a medium trust. however, when i tried to put the external url of flickr in an image control, the image is showing, maybe the issue here is not on medium there any work around here? by the way, here's my code

Flickr flickr = new Flickr(apikey, shared);

PhotoSearchOptions options = new PhotoSearchOptions();
options.UserId = fl.Username;
Photos photos = flickr.PhotosSearch(options);

the error is pointing to Photos photos = flickr.PhotosSearch(options); and then i tried to do this on the image control of the other aspx page

<asp:Image ID="img" runat="server" ImageUrl="" />

the code above did not return any error and successfully showed the exact image. please advice mo on what to do.thank you.
Dec 20, 2007 at 5:08 PM
by the way, i also tried to set Flickr.CacheDisabled = true; and it returned an error "Length Required (411)"
Apr 12, 2008 at 6:27 PM
I have this issue too, my site only has Medium trust, I guess that's the norm, is there any workaround?
My provider says that the fix would be to move to a Dedicated Server.

I'm getting a SecurityException when calling Photos flickrPhotos = flickr.PhotosSearch(searchOptions);
Apr 14, 2008 at 12:05 PM
If your hosting ISP does not allow you to talk to external sites then there is no workaround I'm afraid.

If however it is a different error then it might be solvable.

Have you tried turning caching off (this is a common cause of security exceptions as well)?

Have you tried the following simple code:

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("");

If that throws an exception then there is nothing that can be done except either hassle your provider, upgrade to a dedicated server, or get another provider.