Using the Flickr.net Api on a medium trust server

The photo sharing site Flickr has a nice api which you can use in your own applications. On codeplex is a .net version of this api Flickr.net.

I had to make a little script for a friends project so she could view random flickr photo’s on her site. I made a aspx page using the Flickr.Net dll and it worked perfectly on my own machine. after uploading it to my hosted webserver i ran into trouble. the following error came up when browsing to the aspx page

Exception Details: System.Security.SecurityException: Request for the permission of type ‘System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed.

After some research i came to the conclusion that it had something to do with my site running in a medium trust. The Flickr.Net api uses a caching function standard which doesnt has the right permission on a hosted envoirment.

The real solution was easy after i found out what the real problem was. The only thing i had to do was disable the caching:

Flickr.CacheDisabled = true;

 

After doing this the script was running perfectly. during the search for the solution to this problem i came across a lot of people who had the same problem when deploying their Flickr.net enabled scripts so i thought it was handy to post this simple solution.

Have fun with your Flickr.Net enabled Scripts!

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter