简体   繁体   English

在 ASP.NET 子应用程序中覆盖 web.config

[英]Override web.config in ASP.NET sub-application

IIS 7 .NET 4.0 I have a website with 4 sub-web-applications. IIS 7 .NET 4.0 我有一个包含 4 个子 Web 应用程序的网站。 3 of them need settings from the parent-web.config One should have a completely independent web.config (no inheritance) I am aware of the possibility to turn off inheritance for sub-apps.其中 3 个需要来自 parent-web.config 的设置 一个应该有一个完全独立的 web.config(无继承) 我知道可以为子应用关闭 inheritance。 But what I need is a way to turn it off for only one sub-app.但我需要的是一种只为一个子应用程序关闭它的方法。 (without having to each section individually.. So I am looking for something like a "dontInheritParentConfig" setting in my sub-web.config (不必单独访问每个部分。所以我在我的 sub-web.config 中寻找类似“dontInheritParentConfig”的设置

Thank you!谢谢!

In .net 4 you can use Web.config Transformation Syntax for Web Application Project Deployment .在 .net 4 中,您可以使用Web.config Transformation Syntax for Web Application Project Deployment This is a templating change to web.config to allow the file to be different in different scenarios - which should fit with your sub application need.这是对 web.config 的模板更改,以允许文件在不同情况下有所不同 - 这应该适合您的子应用程序需要。

Web.config files typically include settings that have to be different depending on which environment the application is running in. For example, you might have to change a database connection string or disable debugging when you deploy a Web.config file. Web.config 文件通常包含必须根据应用程序运行的环境而有所不同的设置。例如,您可能必须在部署 Web.config 文件时更改数据库连接字符串或禁用调试。 For Web application projects, ASP.NET provides tools that automate the process of changing (transforming) Web.config files when they are deployed.对于 Web 应用项目,ASP.NET 提供了在部署 Web.config 文件时自动更改(转换)过程的工具。 For each environment that you want to deploy to, you create a transform file that specifies only the differences between the original Web.config file and the deployed Web.config file for that environment.对于您要部署到的每个环境,您创建一个转换文件,该文件仅指定原始 Web.config 文件和为该环境部署的 Web.config 文件之间的差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM