当'https'已经在使用以下web.config时,如何配置IIS web.config以添加'http'连接? [英] How to configure IIS web.config in order to add 'http' connections when 'https' are already working with the following web.config?

查看:103
本文介绍了当'https'已经在使用以下web.config时,如何配置IIS web.config以添加'http'连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,你好b $ b $
   有人可以就以下问题给我一些帮助吗?



    背景



   我启动并运行了一个wcf iis网络服务。 

   网络配置仅接受https连接并且正常工作。



    我的问题



   我还需要添加与http连接的可能性,如何修改现有的web.config来实现这一点?



    My Web.config



<?xml version =" 1.0" encoding =" utf-8"?>

< configuration>

  < system.diagnostics>

  &NBSP; < trace autoflush =" true">

  &NBSP; &NBSP; <听众>

  &NBSP; &NBSP; &NBSP; < add name =" textWriterTraceListener"类型= QUOT; System.Diagnostics.TextWriterTraceListener" initializeData = QUOT; C:\Temp\log4net.txt" />

  &NBSP; &NBSP; < / listeners>

  &NBSP; < / trace>

  < /system.diagnostics>



  < system.web>

  &NBSP; < compilation debug =" true" targetFramework =" 4.5.2">

  &NBSP; &NBSP; < assemblies>

  &NBSP; &NBSP; &NBSP; < add assembly =" System.Data.Entity,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089" />

  &NBSP; &NBSP; < / assemblies>

  &NBSP; < / compilation>

  &NBSP; < customErrors mode =" RemoteOnly"的defaultRedirect = QUOT; mycustompage.htm" />

  < /system.web>

  < system.serviceModel>

  &NBSP; < bindings>

  &NBSP; &NBSP; < webHttpBinding>

  &NBSP; &NBSP; &NBSP; < binding name =" webHttpTransportSecurity">

  &NBSP; &NBSP; &NBSP; &NBSP; < security mode =" Transport" />

  &NBSP; &NBSP; &NBSP; < / binding>

  &NBSP; &NBSP; < / webHttpBinding>

  &NBSP; < / bindings>

  &NBSP; < services>

  &NBSP; &NBSP; < service name =" WSComptaPlus.ServiceComptaPlus" behaviorConfiguration =" ServiceBehaviour">

  &NBSP; &NBSP; &NBSP; < endpoint address ="" 

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; binding =" webHttpBinding" 

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bindingConfiguration =" webHttpTransportSecurity" 

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; behaviorConfiguration =" jsonEndpointBehavior" 

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; name =" json" 

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;合同= QUOT; WSComptaPlus.IServiceComptaPlus" />
$


  &NBSP; &NBSP; &NBSP; < endpoint address =" mex"结合= QUOT; mexHttpsBinding"合同= QUOT; IMetadataExchange接口" />
$


  &NBSP; &NBSP; < / service>

  &NBSP; < / services>

  &NBSP; < behavior>

  &NBSP; &NBSP; < serviceBehaviors>

  &NBSP; &NBSP; &NBSP; < behavior name =" ServiceBehaviour">

  &NBSP; &NBSP; &NBSP; &NBSP; < serviceMetadata httpsGetEnabled =" true" />

  &NBSP; &NBSP; &NBSP; &NBSP; < serviceDebug includeExceptionDetailInFaults =" false" />

  &NBSP; &NBSP; &NBSP; < / behavior>

  &NBSP; &NBSP; < / serviceBehaviors>

  &NBSP; &NBSP; < endpointBehaviors>

  &NBSP; &NBSP; &NBSP; < behavior name =" jsonEndpointBehavior">

  &NBSP; &NBSP; &NBSP; &NBSP; < webHttp />

  &NBSP; &NBSP; &NBSP; < / behavior>

  &NBSP; &NBSP; &NBSP; < behavior name =" wsHttpBinding" />

  &NBSP; &NBSP; < / endpointBehaviors>

  &NBSP; < / behavior>

  &NBSP; < serviceHostingEnvironment multipleSiteBindingsEnabled =" true" />

  < /system.serviceModel>

  < system.webServer>

  &NBSP; < directoryBrowse enabled =" true" />

  &NBSP; < modules runAllManagedModulesForAllRequests =" true" />

  < /system.webServer>

  < runtime>

  &NBSP; < assemblyBinding xmlns =" urn:schemas-microsoft-com:asm.v1">

  &NBSP; &NBSP; < dependentAssembly>

  &NBSP; &NBSP; &NBSP; <! - install-package newtonsoft.json - >

  &NBSP; &NBSP; &NBSP; < assemblyIdentity name =" Newtonsoft.Json"公钥=" 30ad4fe6b2a6aeed"培养= QUOT;中性" />

  &NBSP; &NBSP; &NBSP; < bindingRedirect oldVersion =" 0.0.0.0-11.0.0.0" NEWVERSION = QUOT; 11.0.0.0" />

  &NBSP; &NBSP; < / dependentAssembly>

  &NBSP; < / assemblyBinding>

  < / runtime>

< / configuration>



$
   

Good morning,

   Can someone give me some help about the following issue?

   Context

   I got a wcf iis web service up and running. 
   The web config is made to accept only https connections and works fine.

   My question

   I need to add the possibility to connect with http too, how can I modify the existing web.config to achieve this?

   My Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Temp\log4net.txt" />
      </listeners>
    </trace>
  </system.diagnostics>

  <system.web>
    <compilation debug="true" targetFramework="4.5.2">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webHttpTransportSecurity">
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    <services>
      <service name="WSComptaPlus.ServiceComptaPlus" behaviorConfiguration="ServiceBehaviour">
        <endpoint address="" 
                  binding="webHttpBinding" 
                  bindingConfiguration="webHttpTransportSecurity" 
                  behaviorConfiguration="jsonEndpointBehavior" 
                  name="json" 
                  contract="WSComptaPlus.IServiceComptaPlus" />

        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="jsonEndpointBehavior">
          <webHttp />
        </behavior>
        <behavior name="wsHttpBinding" />
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <directoryBrowse enabled="true" />
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <!-- install-package newtonsoft.json -->
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>


   

推荐答案

您好csi-bxl,

我们唯一需要做的就是将额外的端点添加到服务合同中。 />
您可以参考以下配置。

 
Hi csi-bxl,
The only thing we need do is add the additional endpoint to the service contract.
You could refer to the following configuration.
 
 <system.serviceModel>
    <services>
      <service behaviorConfiguration="mybehavior" name="WcfService1.Service1">
<!--http, https are all configurated-->
        <endpoint address="" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="webbev" bindingConfiguration="https"></endpoint>
        <endpoint address="" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="webbev" bindingConfiguration="http"></endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
      </service>
    </services>
    <bindings>
      <webHttpBinding>
        <binding name="https" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
        <binding name="http">
          <security mode="None"></security>
        </binding>
      </webHttpBinding>
</bindings>




然后我们应该在IIS网站绑定中设置http / https协议绑定。

如果有什么我可以,请随时告诉我帮助。

最好的问候

亚伯拉罕


And then we should set up http/https protocol binding in IIS site binding.
Feel free to let me know if there is anything I can help with.
Best Regards
Abraham


这篇关于当'https'已经在使用以下web.config时,如何配置IIS web.config以添加'http'连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆