This project is read-only.

Medium trust?

Jul 5, 2007 at 2:04 PM
This looks great!

Does PhotoHandler work in a medium trust environment? I've done a quick search, before posting, but nothing came back. I'm really keen to get this up and running on my personal web space but, as it's a shared server, it runs under medium trust.
Jul 5, 2007 at 2:55 PM
Edited Jul 5, 2007 at 2:56 PM
I managed to take five minutes out of work to upload this to my web space... Unfortunately, it doesn't appear to work in medium trust:

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

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.

Source Error:

Line 207: #pragma warning disable 162
Line 208: if (Caching == CacheLocation.Disk) {
Line 209: _imageCacheDir = Path.Combine(HttpRuntime.CodegenDir, "Album");
Line 210: Directory.CreateDirectory(_imageCacheDir);
Line 211: _appPath = HttpRuntime.AppDomainAppPath;
Jul 5, 2007 at 3:05 PM
Edited Jul 5, 2007 at 10:47 PM
I managed to get it working by changing line 209 to:

_imageCacheDir = Path.Combine(HttpRuntime.AppDomainAppPath, "AlbumCache");

I also changed the folder rendering logic so that it ignores the "AlbumCache" folder.

Q: What is the reason for/benefit of using the CodegenDir directory for the album cache?
Jul 17, 2007 at 8:11 PM
The supported way of running the handler in medium trust is to set cacheLocation to memory or none. What you did should work fine but it requires that the folder where you store the cache has write permissions for the user under which the worker process runs. Depending on your hoster, this may be impossible because that would be a security risk that they may not be willing to take.