Syntax ASP.NET MVC:是否有语法来访问web.config中的项目条件编译符号

Syntax ASP.NET MVC:是否有语法来访问web.config中的项目条件编译符号,syntax,compilation,web-config,asp.net-mvc-5,conditional,Syntax,Compilation,Web Config,Asp.net Mvc 5,Conditional,ASP.NET MVC:在web.config中是否有访问项目条件编译符号的语法 e、 我可以在每个地区使用不同的数据库,或者决定是否需要HTTPS,等等 2012年的一个类似问题似乎对此并不乐观: 配置文件不是构建的一部分,因此我不确定您希望通过在那里执行配置转换无法实现的条件来实现什么。XML是标记,它本身不包含任何行为。为此,您需要某种转换引擎 <system.web> <compilation xdt:Transform="RemoveAttributes(de

ASP.NET MVC:在
web.config
中是否有访问项目条件编译符号的语法

e、 我可以在每个地区使用不同的数据库,或者决定是否需要HTTPS,等等

2012年的一个类似问题似乎对此并不乐观:
配置文件不是构建的一部分,因此我不确定您希望通过在那里执行配置转换无法实现的条件来实现什么。XML是标记,它本身不包含任何行为。为此,您需要某种转换引擎

<system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
    <!--
        In the example below, the "Replace" transform will replace the entire 
        <customErrors> section of your web.config file.
        Note that because there is only one customErrors section under the 
        <system.web> node, there is no need to use the "xdt:Locator" attribute.

    <customErrors defaultRedirect="GenericError.htm"
        mode="RemoteOnly" xdt:Transform="Replace">
        <error statusCode="500" redirect="InternalError.htm"/>
    </customErrors>
-->
    <sessionState xdt:Transform="Remove"/>
    <trace xdt:Transform="Remove"/>
</system.web>
在上面的示例中,如果条件编译字段包含
MVC2
,则包括第一组引用,如果它包含
MVC3
,则包括第二组引用。请注意,符号以分号分隔

<DefineConstants>MVC2;NET35;</DefineConstants>
MVC2;NET35;
<DefineConstants>MVC2;NET35;</DefineConstants>