When changing application pool identity you also need to change the file permissions for your site. ImageGen runs under the application pool 'owner' and needs to be able to read, write, and create files in the /data folder as well as wherever the images you are processing reside (typically the /media folder for umbraco sites).
Please double-check your file permissions now that you've changed to the 'ApplicationPoolIdentity'. I've found this blog post very helpful to understand how to set file permissions when using the ApplicationPoolIdentity, http://stevesmithblog.com/blog/working-with-application-pool-identities/
It may be that the /config/imagegen.config file can no longer be read and needs file permissions changed as well.
When you check the version you should see your Pro domains listed. http://example.com/umbraco/imagegen.ashx?version If not then there is a problem with the web.config or imagegen.config file (which could certainly be file permissions-related).
The thing is that I have checked the permissions and everything seems to be in order.
This is my error message for the images:
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.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
ImageGen.ImageGenQueryStringParser.Process(HttpContext context) +0
RequestHandler.ProcessRequest(HttpContext context) +36
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016
It sure looks like more changed than just the application pool's owner if you're getting a security error. Any chance you're trying to run in less than full trust? ImageGen does not yet support medium trust, for instance.
I was hitting the same problem as Kalle and managed to resolve the issue see details below.
I am running IIS7
I have full trust set up in the web.config.
I was still getting the error and looked at what identity the AppPool was running under, I had to change it from ApplicationPool to NetworkService
I hope this helps
Server Error in '/' Application.
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.Web.AspNetHostingPermission,
System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
Source Error:
Line 11: { Line 12: ImageGen.ImageGenQueryStringParser parser = new ImageGen.ImageGenQueryStringParser(); Line 13: parser.Process(context); Line 14: } Line 15: }
I changed it from the default IIS7 user (slipped my mind for now) to the network service, it could very well have been permissions related, but the Network Service User worked for me (I had all permissions set up for it).
ImageGen Pro crashes when changing to ApplicationPoolIdentity
Hi there Doug,
When we tried to change an already existing site from using "NETWORK SERVICE" to using "AplicationPoolIdentity" all the PRO features stops to work.
We changed another site just before this one that soes not use PRO features and that one went slick.
Any ideas?
Hi, Kalle,
When changing application pool identity you also need to change the file permissions for your site. ImageGen runs under the application pool 'owner' and needs to be able to read, write, and create files in the /data folder as well as wherever the images you are processing reside (typically the /media folder for umbraco sites).
Please double-check your file permissions now that you've changed to the 'ApplicationPoolIdentity'. I've found this blog post very helpful to understand how to set file permissions when using the ApplicationPoolIdentity, http://stevesmithblog.com/blog/working-with-application-pool-identities/
cheers,
doug.
Hi again,
Did that as well. but still it will not work. Also I tried to do an IIS reset but the problem is still there.
//Kalle
It may be that the /config/imagegen.config file can no longer be read and needs file permissions changed as well.
When you check the version you should see your Pro domains listed. http://example.com/umbraco/imagegen.ashx?version If not then there is a problem with the web.config or imagegen.config file (which could certainly be file permissions-related).
cheers,
doug.
Hi Doug,
The thing is that I have checked the permissions and everything seems to be in order.
This is my error message for the images:
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.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016
It sure looks like more changed than just the application pool's owner if you're getting a security error. Any chance you're trying to run in less than full trust? ImageGen does not yet support medium trust, for instance.
cheers,
doug.
Hello again Doug,
Nope, it runs in full trust.
Any more ideas? I am gonna try to change the application pool again later tonigt.
//Kalle
Hi, Kalle,
Anything to report on this? Have you found a solution or some consistent behavior that might point in the direction of a solution?
cheers,
doug.
Hi Doug,
No, still the same problem. I dont really know what to do.
As for now, this is the only site running with NETWORK SERVICE instead of ApplicationPoolIdentity.
//Kalle
Hi,
I was hitting the same problem as Kalle and managed to resolve the issue see details below.
I hope this helps
Server Error in '/' Application.
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.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
Source File: d:\Repository\MySite\umbraco\ImageGen.ashx Line: 13
Stack Trace:
any new ideas on this?
I got it working by changing the user that the app pool runs under.
What user did you change it to, out of curiosity? And what was it when it didn't run properly?
Hard to imagine it is related (unless file-permission related) but would be nice to know just the same.
cheers,
doug.
Hi Doug,
I changed it from the default IIS7 user (slipped my mind for now) to the network service, it could very well have been permissions related, but the Network Service User worked for me (I had all permissions set up for it).
Cheers,
B
is working on a reply...