首页 文章

部署时抛出SecurityException

提问于
浏览
1

我刚刚编写了一个MVC应用程序,并在我的实验室中使用它 . 现在我已经将它部署到GoDaddy,我收到以下错误 .

描述:应用程序尝试执行安全策略不允许的操作 . 要授予此应用程序所需的权限,请与系统管理员联系或在配置文件中更改应用程序的信任级别 . 异常详细信息:System.Security.SecurityException:请求失败 . 源错误:在执行当前Web请求期间生成了未处理的异常 . 可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息 .

堆栈跟踪:

[SecurityException:Request failed . ] System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm,PermissionSet grant,PermissionSet denied,RuntimeMethodHandleInternal rmh,SecurityAction action,Object demand,IPermission permThatFailed)165 System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString,PermissionSet grant,PermissionSet denied,RuntimeMethodHandleInternal rmh,SecurityAction action,Object demand,IPermission permThatFailed)100 System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants,PermissionSet refused,PermissionSet requirements,RuntimeMethodHandleInternal rmh,Object assemblyOrString,SecurityAction action,Boolean throwException)284 System . Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs,PermissionSet grants,PermissionSet refused,PermissionSet requirements,RuntimeMethodHandleInternal rmh,RuntimeAssembly asm,SecurityAction action)70 System.RuntimeTypeHandle.Get TypeByName(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缓存Hash)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

我想知道我的数据库连接字符串,虽然错误似乎没有暗示数据库的任何问题 .

所以我真正的问题是:如何解决这个问题 . 这些消息似乎根本没有帮助 . 下一步可能是什么?

2 回答

  • 2

    似乎问题是“信任级别” . 您需要在web.config中为站点指定所需的信任级别 . 但问题是GoDaddy可能不允许您的网站所需的信任级别 . 其中一个信任级别允许/不允许例如反射(例如,IoC容器使用反射或AutoMapper) .

    信任级别的东西是微软已经声明它们不再支持的东西,因此任何使它不安全的错误修正都不再是固定的 . 因此,一个解决方案可能是找到另一个webhost是对web.config的更改不能解决您的问题 .

    示例配置:

    <system.web>
      <securityPolicy>
        <trustLevel name="Full" policyFile="internal"/>
      </securityPolicy>
    </system.web>
    
  • 2

    这似乎是我用来构建我的应用程序的.NET版本与主机上提供的版本不匹配的问题 .

    感谢Microsoft提供的另一条错误消息,似乎没有告诉我底层问题是什么 .

相关问题