2017-09-14 30 views
0

我有一個ASP.NET Web應用程序在我的web.config文件的部分看起來像下面ASP.NET設置認證通過的parameters.xml

<security> 
    <authentication> 
    <windowsAuthentication enabled="true"> 
     <providers> 
     <clear /> 
     <add value="NTLM" /> 
     <add value="Negotiate" /> 
     </providers> 
    </windowsAuthentication> 
    <anonymousAuthentication enabled="false" /> 
    </authentication> 
</security> 

在另一方面,我配置了的parameters.xml文件(基於https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/web-deployment-in-the-enterprise/configuring-parameters-for-web-package-deployment)根據我的環境定義不同的設置以及不同的< _APPNAME>。 < _ENVIRONMENT> .SetParameters.xml文件。

我想弄清楚如何通過Parameters.xml定義不同的身份驗證設置?

  • 在環境A,我需要有windowsAuthentication啓用= 「真」 (和anonymousAuthentication啓用= 「假」)
  • 在環境B,我需要有anonymousAuthentication
    啓用=」 true「
    (和windowsAuthentication enabled =」false「)

回答

0

至少對於AppSettings,您可以使用configSource參數。我相信你也可以爲其他部分。

<security configSource="config\default.config" /> 

而當你部署到不同的環境中,你可以使用的web.config變換(https://msdn.microsoft.com/en-us/library/dd465318(v=vs.100).aspx

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
<security configSource="config\envASettings.config" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />