托管 ASP.NET MVC 应用程序:安全异常
Hosting ASP.NET MVC Application: Security Exception
我有一个 ASP.NET MVC 5 应用程序,可以在开发机器上正常运行。我发布了它并在线传输了文件,它产生了以下错误:
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 failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[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) +272
System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, RuntimeAssembly asm, SecurityAction action) +55
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) +39
System.Type.GetType(String typeName) +50
System.CodeDom.Compiler.CompilerInfo.get_IsCodeDomProviderTypeValid() +10
System.Web.Compilation.CompilationUtil.GetRecompilationHash(CompilationSection ps) +2090
System.Web.Configuration.CompilationSection.get_RecompilationHash() +107
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDateInternal(Int64 cachedHash) +465
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate(Int64 cachedHash) +51
System.Web.Compilation.BuildManager.ExecutePreAppStart() +132
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521
我的主机为我提供了一个 ASP.NET 设置面板。
我的设置如下:
Framework version: 4.0.30319.17929
Default webpage language: C#
CAS trust level: FULL
任何人都可以指导我什么是问题。是应用程序还是主机?
大多数托管服务提供商现在都提供 FULL Trust 托管服务。 MVC 不接受部分信任。
<system.web>
<trust level="Full" />
</system.web>
如果这不起作用如果您无法访问服务器,您应该联系您的托管服务提供商。
我们所做的是 运行 我们开发中的以下内容。
<system.web>
<trust level="Medium"/>
</system.web>
更改信任级别会使暂存环境失败并在共享主机上显示相同的错误,因此您可以更正代码以符合您的主机。
如果您要部署到中等信任的托管环境,您最好预先将信任级别设置为中等,以节省时间和精力。
这是一个link
我有一个 ASP.NET MVC 5 应用程序,可以在开发机器上正常运行。我发布了它并在线传输了文件,它产生了以下错误:
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 failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[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) +272
System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, RuntimeAssembly asm, SecurityAction action) +55
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) +39
System.Type.GetType(String typeName) +50
System.CodeDom.Compiler.CompilerInfo.get_IsCodeDomProviderTypeValid() +10
System.Web.Compilation.CompilationUtil.GetRecompilationHash(CompilationSection ps) +2090
System.Web.Configuration.CompilationSection.get_RecompilationHash() +107
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDateInternal(Int64 cachedHash) +465
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate(Int64 cachedHash) +51
System.Web.Compilation.BuildManager.ExecutePreAppStart() +132
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521
我的主机为我提供了一个 ASP.NET 设置面板。
我的设置如下:
Framework version: 4.0.30319.17929
Default webpage language: C#
CAS trust level: FULL
任何人都可以指导我什么是问题。是应用程序还是主机?
大多数托管服务提供商现在都提供 FULL Trust 托管服务。 MVC 不接受部分信任。
<system.web>
<trust level="Full" />
</system.web>
如果这不起作用如果您无法访问服务器,您应该联系您的托管服务提供商。
我们所做的是 运行 我们开发中的以下内容。
<system.web>
<trust level="Medium"/>
</system.web>
更改信任级别会使暂存环境失败并在共享主机上显示相同的错误,因此您可以更正代码以符合您的主机。 如果您要部署到中等信任的托管环境,您最好预先将信任级别设置为中等,以节省时间和精力。
这是一个link