如何在Medium Trust中写入Web.Config?

funde 发布于 2018-02-04 asp.net 最后更新 2018-02-04 01:02 468 浏览

上传我的第一个体面大小的网络应用程序到我的共享主机为我提供了一个新的挑战,我的意思是,不眠之夜。问题是,我当然没有开发我的中等信任申请(或者有什么线索)。 我减轻了所有的问题,除了一个。 我已经写了一个管理员的安装程序能够指定他们的连接字符串和其他首选项,但我找不到一个方法来写入中等信任的web.config。有没有人有解决方案,或者我应该只是在其他文件的偏好?

已邀请:

det

赞同来自:

这实际上听起来像IIS的Low级别。如果是,那么你将无法写入任何文件,而不仅仅是web.config。 以下是IIS帮助文件中的级别:

  • Full (internal) - Specifies unrestricted permissions. Grants the ASP.NET application permissions to access any resource that is subject to operating system security. All privileged operations are supported.
  • High (web_hightrust.config) - Specifies a high level of code access security, which means that the application cannot do any one of the following things by default:
    • Call unmanaged code.
    • Call serviced components.
    • Write to the event log.
    • Access Message Queuing service queues.
    • Access ODBC, OleDb, or Oracle data sources.
  • Medium (web_mediumtrust.config) - Specifies a medium level of code access security, which means that, in addition to High Trust Level restrictions, the ASP.NET application cannot do any of the following things by default:
    • Access files outside the application directory.
    • Access the registry.
    • Make network or Web service calls.
  • Low (web_lowtrust.config) - Specifies a low level of code access security, which means that, in addition to Medium Trust Level restrictions, the application cannot do any of the following things by default:
    • Write to the file system.
    • Call the Assert method.
  • Minimal (web_minimaltrust.config) - Specifies a minimal level of code access security, which means that the application has only execute permissions.
我建议,如果你已经设置了一个安装程序,让它在内存中创建一个web.config,用户可以在本地保存FTP