当有一个发布编译时,我需要在我的web.config中将此块添加到我的绑定中:
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
这是我的web.config的片段:
<bindings>
<basicHttpBinding>
<binding name="BasicBinding" closeTimeout="24.20:31:23.6470000" openTimeout="24.20:31:23.6470000" receiveTimeout="24.20:31:23.6470000" sendTimeout="24.20:31:23.6470000" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
这是我的转换方法web.release.config跟随这个documentation:
<bindings>
<basicHttpBinding>
<binding>
<security mode="Transport" xdt:Transform="InsertAfter(/configuration/system.serviceModel/bindings/basicHttpBinding/binding)">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
在VSTS上编译时遇到以下错误:
[error] Sources \ Foo.Interface \ Web.Release.config(16,6):错误:源文档中没有元素匹配'/ configuration / bindings / basicHttpBinding'
当然,我尝试过其他类似的值,但面对同样的问题。
不清楚错误。但是如果要将安全节点插入web.config的绑定节点,可以使用xdt在web.release.config中编写以下代码:Transform =“Insert”
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicBinding" >
<security mode="Transport" xdt:Transform="Insert" >
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>