1

So I made this app that runs fine on my local pc but I get the following error when I've uploaded it to my website:

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 failed.

I searched around to solve this issue and found that adding the <trust /> element to the root-level web.config would fix the issue. I checked what trust level I had configured on my website in the ASP.NET settings (in this case it was set to High) so I did this in the correct web.config:

<system.web>
    <securityPolicy>
        <trustLevel name="High" policyFile="web_hightrust.config"/>
    </securityPolicy>
    <customErrors mode="Off"/>
    <authentication mode="None"/>
    <compilation debug="true" targetFramework="4.6.1"/>
    <httpRuntime targetFramework="4.6.1"/>
    <httpModules>
        <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
    </httpModules>
</system.web>

This hasn't fixed my issue and I'm left with no avenues to explore to try and solve this. Below is the stack trace that I am given with the above error

[SecurityException: Request failed.]
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +165
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100
System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +284
System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, RuntimeAssembly asm, SecurityAction action) +70
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +70
System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +40
System.Type.GetType(String typeName) +30
System.CodeDom.Compiler.CompilerInfo.get_IsCodeDomProviderTypeValid() +12
System.Web.Compilation.CompilationUtil.GetRecompilationHash(CompilationSection ps) +2175
System.Web.Configuration.CompilationSection.get_RecompilationHash() +96
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDateInternal(Int64 cachedHash) +458
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate(Int64 cachedHash) +51
System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531
tereško
  • 58,060
  • 25
  • 98
  • 150
Skate
  • 11
  • 4

1 Answers1

2

This sounds like an issue with your hosting provider running on partial trust, which is no longer officially supported by Microsoft. You should:

  1. Confirm that your hosting provider is indeed using partial trust.
  2. Insist that they remove it because it is no longer supported.
  3. If they don't comply, find a new hosting provider that supports full trust.
Community
  • 1
  • 1
NightOwl888
  • 55,572
  • 24
  • 139
  • 212
  • 1
    I went back into the ASP.NET settings and they do have the `Full` option so I selected this and changed the web.config to: `` but I still the get the same error. – Skate Mar 18 '16 at 18:47