如何在中等信任中写入 Web.Config?

发布于 2024-07-03 23:54:51 字数 226 浏览 8 评论 0原文

将我的第一个大小合适的网络应用程序上传到我的共享主机给我带来了一系列新的挑战,我的意思是,不眠之夜。 问题是,我肯定没有开发出中等信任度的应用程序(或者不知道那是什么。)

我缓解了所有问题,除了一个问题。

我已经为管理员编写了一个安装程序,以便能够指定他们的连接字符串和其他首选项,但我找不到以中等信任度写入 web.config 的方法。 有谁有解决方案,或者我应该将首选项放在另一个文件中?

Uploading my first decently sized web app to my shared host provided me with a fresh set of challenges, by which I mean, sleepless nights. The issue was that I had most certainly not developed my application for medium trust (or had any clue what that was.)

I mitigated all of the issues, save one.

I had written an installer for the admin to be able to specify their connection string and other preferences, but I cannot find a way to write to a web.config in medium trust. Does anyone have a solution, or should I just be putting preferences in another file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笙痞 2024-07-10 23:54:51

这实际上听起来像是 IIS 的级别。 如果是,那么您将无法写入任何文件,而不仅仅是 web.config。

以下是 IIS 帮助文件中的级别:

  • 完全(内部)- 指定不受限制的权限。 授予 ASP.NET 应用程序访问受操作系统安全约束的任何资源的权限。 支持所有特权操作。
  • 高 (web_hightrust.config) - 指定高级别的代码访问安全性,这意味着应用程序默认情况下无法执行以下任一操作:
    • 调用非托管代码。
    • 调用服务组件。
    • 写入事件日志。
    • 访问消息队列服务队列。
    • 访问 ODBC、OleDb 或 Oracle 数据源。
  • 中 (web_mediumtrust.config) - 指定中等级别的代码访问安全性,这意味着除了高信任级别限制之外,ASP.NET 应用程序默认情况下无法执行以下任何操作:
    • 访问应用程序目录之外的文件。
    • 访问注册表。
    • 进行网络或 Web 服务调用。
  • 低 (web_lowtrust.config) - 指定低级别的代码访问安全性,这意味着除了中信任级别限制之外,应用程序默认情况下无法执行以下任何操作:
    • 写入文件系统。
    • 调用 Assert 方法。
  • 最小 (web_minimaltrust.config) - 指定最低级别的代码访问安全性,这意味着应用程序仅具有执行权限。

我建议,如果您执意要安装程序,请让它在内存中创建一个 web.config ,用户可以将其保存在本地,然后再通过 FTP 上传。

That actually sounds like IIS's Low level. If it is, then you won't be able to write to any file, not just the web.config.

Here are the levels from IIS's help file:

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

I would suggest that if you are dead set on having an installer, have it create a web.config in memory that the user can save locally and FTP up afterward.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文