【问题标题】:ASP.Net on actual site yields security exception实际站点上的 ASP.Net 产生安全异常
【发布时间】:2013-07-12 15:03:18
【问题描述】:

我删除并重新创建了 ASP.Net 站点的子域。然后我上传了文件,但是当我打开浏览器时,我得到一个安全异常,指出我必须修改应用程序的配置文件以授予信任。遗憾的是,错误消息没有说明导致问题的文件、存在问题的信任或我能看到的任何内容。

这是我看到的:

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.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error: 


[No relevant source lines]

Source File: App_Web_iqeawexe.0.cs    Line: 0 

Stack Trace: 


[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
   System.Security.CodeAccessPermission.Demand() +46
   System.Reflection.RuntimeAssembly.VerifyCodeBaseDiscovery(String codeBase) +118
   System.Reflection.RuntimeAssembly.GetName(Boolean copiedName) +69
   System.Reflection.Assembly.GetName() +12
   DevExpress.Web.ASPxClasses.Internal.HttpUtils.<get_DXValidatorType>b__0(Assembly i) +9
   System.Linq.WhereArrayIterator`1.MoveNext() +55
   System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +4216052
   DevExpress.Web.ASPxClasses.Internal.HttpUtils.get_DXValidatorType() +120
   DevExpress.Web.ASPxClasses.Internal.HttpUtils.GetValueFromRequest(HttpRequest request, String key, Boolean skipValidation) +25
   DevExpress.Web.ASPxClasses.Internal.HttpUtils.GetValueFromRequest(String key, Boolean skipValidation) +60
   DevExpress.Web.ASPxClasses.Internal.MvcUtils.get_CallbackName() +79
   DevExpress.Web.ASPxClasses.Internal.RenderUtils.IsAnyCallback(Page page) +51
   DevExpress.Web.ASPxClasses.Internal.ResourceRegistrator.EnsureResourcesSynchronized(Page page) +55
   DevExpress.Web.ASPxClasses.Internal.ResourceRegistrator.RegisterResource(Page page, ResourceData resource, Boolean useStandardRegistration) +19
   DevExpress.Web.ASPxClasses.ASPxWebControl.RegisterHoverIncludeScripts() +84
   DevExpress.Web.ASPxClasses.ASPxWebControl.RegisterClientIncludeScripts() +72
   DevExpress.Web.ASPxClasses.ASPxWebControl.OnPreRender(EventArgs e) +96
   DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.OnPreRender(EventArgs e) +32
   System.Web.UI.Control.PreRenderRecursiveInternal() +103
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253
   System.Web.UI.Page.ProcessRequest() +78
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.default_aspx.ProcessRequest(HttpContext context) in App_Web_iqeawexe.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

想法?

【问题讨论】:

  • 您是否以中等信任度运行?
  • 我认为我是中等信任度。我在一个共享的托管环境中,所以它是什么产生的。我想我记得以前与网络托管服务提供商的通信中确实如此。有趣的是,该网站过去运行良好。上周计算机崩溃了,他们托管了我的帐户。他们重建了东西,但使用了旧版本的备份,无论如何。我决定最简单的方法是删除子域,重新创建子域,然后再次上传文件。但是,该操作仍然产生相同的错误消息。
  • 我知道在共享托管环境中不允许我“完全信任”,并且该站点运行良好。当 Web 主机提供商重建机器时,他们可能会更改信任级别并使其比 ASP.Net / DevExpress 喜欢的更严格。我不知道哪个组件实际上导致了故障。我不清楚堆栈跟踪。
  • 我会联系网络托管公司并听取他们的意见。
  • 请注意,Medium Trust 不是很安全,已被 Microsoft 弃用。向他们发送指向 stackoverflow.com/a/17218344/34397(由 ASP.Net 安全团队的一位开发人员提供)和 support.microsoft.com/kb/2698981 的链接,并要求他们切换到更安全的隔离。

标签: asp.net security file-permissions trust


【解决方案1】:

这个问题原来是 DevExpress 版本中的一个缺陷。 7 月 8 日发布的版本破坏了使用中等信任模型的网站。他们发布了一个修补程序。

这是 DevExpress 写给我的:“在中等信任环境票证中更新到 DevExpress 2013.1.5 后,我们已经在 System.Security.Permissions.FileIOPermission 异常的上下文中修复了这个问题。我建议你下载一个修复程序并检查问题是否仍然存在。”

我没想到大公司不做彻底的测试,这就是让这个错误难以追踪的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-02
    • 2016-07-05
    • 2011-04-25
    • 2010-09-19
    • 1970-01-01
    • 2010-11-29
    相关资源
    最近更新 更多