WCF基于HTTPS接口的Web.config配置

基于HTTPS接口的Web.config配置,需要的朋友可以直接用。

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

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="DefectImagesUrl" value="/Content/images/bridge/defect/" />
    <add key="CbmsFile" value="D:/Repository/trunk/CBMS/CBMS" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
    <authentication mode="Forms" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>
  </system.web>
  <system.serviceModel>

    <!--用来支持https-->
    <bindings>
      <webHttpBinding>
        <binding name="SecureWebBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </webHttpBinding>
      <!--新加-->
      <basicHttpBinding>
        <!--其实要修改所有的服务,不管是服务端还是客户端,Binding那边增加一个没有设置名字的默认配置就OK了-->
        <binding closeTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
        </binding>
      </basicHttpBinding>
      <!--新加-->
    </bindings>
    <!--用来支持https-->



    <services>
      <service name="CBMSWCF.Service1">
        <endpoint address="" behaviorConfiguration="CBMSWCF.Service1AspNetAjaxBehavior" binding="webHttpBinding" contract="CBMSWCF.IService1" />
        <!--用来支持https-->
        <!--<endpoint address=""
                  binding="webHttpBinding"
                  bindingConfiguration="SecureWebBinding"
                  contract="CBMSWCF.IService1"
                  behaviorConfiguration="CBMSWCF.Service1AspNetAjaxBehavior"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>-->
        <!--用来支持https-->
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="CBMSWCF.Service1AspNetAjaxBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />


          <!--新加-->
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <!--新加-->


        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />-->

    <!--新加-->
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="1" />
    <!--新加-->


  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
    <!--
        若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
        在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
      -->
    <directoryBrowse enabled="true" />
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <!--这里是entityFramework的配置-->
  <connectionStrings>
    <add name="" connectionString="" />
  <add name="" connectionString="" providerName="" /> </connectionStrings> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="mssqllocaldb" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework> <!--这里是entityFramework的配置--> </configuration>

猜你喜欢

转载自www.cnblogs.com/yangwujun/p/9214322.html