我有 2 个 app.config 文件用于 https 访问,另一个用于 http 访问,如果我有两个选项按钮,一个用于 http,另一个用于 https,如果用户选择第一个选项,即 http,我如何存储在 C:\program安装我的应用程序时的文件,并让我的应用程序只使用 httpsapp.config 文件而不是 httpapp.config 文件。
或者我如何使我的 app.config 文件同时适用于 https 和 http。
以下是我的 app.config 文件,目前正在为 http 工作
<system.serviceModel>
<standardEndpoints />
<bindings>
<webHttpBinding>
<binding name="Bind1" crossDomainScriptAccessEnabled="true" maxReceivedMessageSize="900000" maxBufferSize="900000" />
</webHttpBinding>
</bindings>
<services>
<service name="PeripheralServiceImpl" behaviorConfiguration="SvcBhvr">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="EndPBhvr" bindingConfiguration="Bind1" contract="Server.Contract.IPeripheralService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:18732/Peripheral/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="EndPBhvr">
<webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" faultExceptionEnabled="false" defaultBodyStyle="Wrapped" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SvcBhvr">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
</system.serviceModel>
并且 app.config 在 https 中工作
<system.serviceModel>
<standardEndpoints />
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<bindings>
<basicHttpBinding>
<binding name ="soapBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<!--<binding name="httpBinding">-->
<binding name="Bind1" crossDomainScriptAccessEnabled="true" maxReceivedMessageSize="900000" maxBufferSize="900000" >
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="PeripheralServiceImpl" behaviorConfiguration="SvcBhvr">
<host>
<baseAddresses>
<add baseAddress="https://localhost:18732/Peripheral/" />
</baseAddresses>
</host>
<endpoint address="https://localhost:18732/Peripheral/" binding="webHttpBinding" behaviorConfiguration="EndPBhvr" bindingConfiguration="Bind1"
contract="Server.Contract.IPeripheralService">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="EndPBhvr">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SvcBhvr">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
任何人都可以帮助我吗?