簡體   English   中英

在IIS Express ssl上托管的WCF已啟用

[英]WCF hosted on IIS express ssl enabled

我已經敲了一個星期,我正在嘗試在IIS express上運行WCF服務並從瀏覽器執行GET ,在HTTP中一切正常,但是嘗試使用HTTPS失敗的那一分鍾

HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

我已經嘗試了stackoverflow答案中的每個配置文件,但我也嘗試過這樣做,我知道它是針對IIS的,但是我看不到為什么它在IIS express上不起作用。 這是我的配置文件:

<?xml version="1.0"?>
<configuration>


  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>


  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <behaviors>
      <endpointBehaviors>

        <behavior name="webHttpEnablingBehaviour">

          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>

        <behavior name="webHttpEnablingBehaviour">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>

      </serviceBehaviors>
    </behaviors>
    <services>
      <service
        name="ElasticSearchAPI.GetElasticService" behaviorConfiguration="webHttpEnablingBehaviour">
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />

        <endpoint address=""
          binding="webHttpBinding"
          bindingConfiguration="default"
          contract="ElasticSearchAPI.IGetElasticService"
          behaviorConfiguration="webHttpEnablingBehaviour">
        </endpoint>
        <endpoint address="other"
          binding="basicHttpBinding"
          bindingConfiguration="default"
          contract="ElasticSearchAPI.IGetElasticService">
        </endpoint>
      </service>

    </services>
    <client />
    <bindings>
      <webHttpBinding>
        <binding name="default" ></binding>
      </webHttpBinding>
      <basicHttpBinding>
        <binding name="default" allowCookies="true"></binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <validation validateIntegratedModeConfiguration="false"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>

    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>

  </system.webServer>

</configuration>

我確信我確實缺少一些愚蠢的東西,但是我真的沒有想法,非常感謝您的幫助。

更新

我可以通過https進入我的.svc,但是當我嘗試從瀏覽器獲取信息或從fiddler發布信息時,卻無濟於事

如下使用ServiceBehaviour-

<serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
</behavior>

這可能對您有幫助。

在WCF服務配置文件中,添加以下內容:

<binding name="secureHttpBinding">
 <security mode="Transport">
  <transport clientCredentialType="None" />
 </security>
</binding>

在客戶端應用程序配置文件中添加以下內容:

<httpProtocol>
 <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
 </customHeaders>
</httpProtocol>

這將允許您使用HTTPS協議托管和訪問WCF服務。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM