Asp.net mvc web.config转换不工作
在MVC应用程序中,我有一个为我的开发环境设置的web.config,我有一个需要插入新WCF服务端点的转换文件,但是它将其添加到了错误的位置,所以我认为我遗漏了一些东西 我减少了配置文件,只显示所需的内容 我的普通web.config如下所示:Asp.net mvc web.config转换不工作,asp.net-mvc,web-config,transform,transformation,Asp.net Mvc,Web Config,Transform,Transformation,在MVC应用程序中,我有一个为我的开发环境设置的web.config,我有一个需要插入新WCF服务端点的转换文件,但是它将其添加到了错误的位置,所以我认为我遗漏了一些东西 我减少了配置文件,只显示所需的内容 我的普通web.config如下所示: <services> <!-- Report Service --> <service name="Core.ReportDataHost"> <endpoint name="ReportDat
<services>
<!-- Report Service -->
<service name="Core.ReportDataHost">
<endpoint name="ReportDataHost" address="..." binding="customBinding" contract="..."/>
</service>
<!-- Authentication Service -->
<service name="Core.AuthenticationHost">
<endpoint name="AuthenticationHost" address="..." binding="customBinding" contract="..."/>
</service>
</services>
<services>
<service name="Core.AuthenticationHost">
<endpoint xdt:Transform="Insert" address="" binding="customBinding" contract="..." />
</service>
</services>
然后,我得到如下转换文件:
<services>
<!-- Report Service -->
<service name="Core.ReportDataHost">
<endpoint name="ReportDataHost" address="..." binding="customBinding" contract="..."/>
</service>
<!-- Authentication Service -->
<service name="Core.AuthenticationHost">
<endpoint name="AuthenticationHost" address="..." binding="customBinding" contract="..."/>
</service>
</services>
<services>
<service name="Core.AuthenticationHost">
<endpoint xdt:Transform="Insert" address="" binding="customBinding" contract="..." />
</service>
</services>
我希望这会在“AuthenticationHost”服务中添加新端点,但它会将其添加到第一个服务“ReportDataHost”
你知道我遗漏了什么吗 默认情况下,转换只使用标记,而不使用属性,因此,即使转换中有name=“Core.AuthenticationHost”,它也将被忽略,并且仅使用它找到的第一个服务标记匹配服务标记 在
标记中添加一个定位器,以便它知道要使用哪个定位器(而不是只使用第一个定位器)。定位器是标签上的一个属性:xdt:Locator=“Match(attribute1,attribute2,…”
。在这种情况下,您希望在名称
属性上进行匹配
更正后的变换将如下所示:
<services>
<service name="Core.AuthenticationHost" xdt:Locator="Match(name)">
<endpoint xdt:Transform="Insert" address="" binding="customBinding" contract="..." />
</service>
</services>
有关更多信息,请访问。Super,这是有道理的,我将在明天回来工作时尝试此功能。谢谢