C# web.config中的web.release.config转换

C# web.config中的web.release.config转换,c#,asp.net,vb.net,C#,Asp.net,Vb.net,目前,在我的web.config文件中 <configuration> <general path="c:\abc\" /> </configuration> 这对最终的web.config没有影响。它仍然会在我想要的“D:\”位置显示“C:\”您可以尝试将这些属性添加到Web.Release.config: <?xml version="1.0" encoding="utf-8"?> <configuration xmlns:xd

目前,在我的
web.config
文件中

<configuration>
    <general path="c:\abc\" />
</configuration>

这对最终的web.config没有影响。它仍然会在我想要的“D:\”位置显示“C:\”

您可以尝试将这些属性添加到Web.Release.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>
  <General dataFilePath="D:\Data" xdt:Transform="SetAttributes" xdt:Locator="Match(dataFilePath)" />
  <AuditManagement auditPath="D:\Audit"  xdt:Transform="SetAttributes" xdt:Locator="Match(auditPath)"  />
</configuration>
xdt:Transform="SetAttributes" xdt:Locator="Match(path)"
因此,您的最终结果应该是:

<configuration>
    <general path="d:\abc\" xdt:Transform="SetAttributes" xdt:Locator="Match(path)"/>
</configuration>

您可以尝试将这些属性添加到Web.Release.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>
  <General dataFilePath="D:\Data" xdt:Transform="SetAttributes" xdt:Locator="Match(dataFilePath)" />
  <AuditManagement auditPath="D:\Audit"  xdt:Transform="SetAttributes" xdt:Locator="Match(auditPath)"  />
</configuration>
xdt:Transform="SetAttributes" xdt:Locator="Match(path)"
因此,您的最终结果应该是:

<configuration>
    <general path="d:\abc\" xdt:Transform="SetAttributes" xdt:Locator="Match(path)"/>
</configuration>

我建议您使用转换

首先,您必须为调试或发布创建不同的环境,如果需要,还可以添加更多

我对本教程进行了很好的解释和测试:

以下是官方文件:

如前一节所述,web.config的配置如下:

<configuration>
    <general path="d:\abc\" xdt:Transform="SetAttributes" xdt:Locator="Match(path)"/>
</configuration>


然后,您必须在调试和Realease配置中定义正确的路径,一旦完成,您将使用您设置的配置之一运行应用程序。

我建议您使用转换

首先,您必须为调试或发布创建不同的环境,如果需要,还可以添加更多

我对本教程进行了很好的解释和测试:

以下是官方文件:

如前一节所述,web.config的配置如下:

<configuration>
    <general path="d:\abc\" xdt:Transform="SetAttributes" xdt:Locator="Match(path)"/>
</configuration>


然后,您必须在调试和Realease配置中定义正确的路径,一旦完成,您将使用您设置的配置之一运行应用程序。

我尝试了这个,但失败了。未对web.config进行任何更改。我用我所做的更改更新了我的问题(上面)。谢谢我试过了,但失败了。未对web.config进行任何更改。我用我所做的更改更新了我的问题(上面)。谢谢