ServiceMetadataBehavior 的 HttpsGetEnabled 屬性設置為 True,而 HttpsGetUrl 屬性是相對地址,但沒有 https 基址


WCF 發布,本機正常,服務器報錯,信息如下:

ServiceMetadataBehavior 的 HttpsGetEnabled 屬性設置為 True,而 HttpsGetUrl 屬性是相對地址,但沒有 https 基址。請提供 https 基址或將 HttpsGetUrl 設置為絕對地址。

說明: 執行當前 Web 請求期間,出現未經處理的異常。請檢查堆棧跟蹤信息,以了解有關該錯誤以及代碼中導致錯誤的出處的詳細信息。 

異常詳細信息: System.InvalidOperationException: ServiceMetadataBehavior 的 HttpsGetEnabled 屬性設置為 True,而 HttpsGetUrl 屬性是相對地址,但沒有 https 基址。請提供 https 基址或將 HttpsGetUrl 設置為絕對地址。

源錯誤: 

執行當前 Web 請求期間生成了未經處理的異常。可以使用下面的異常堆棧跟蹤信息確定有關異常原因和發生位置的信息。

堆棧跟蹤: 


[InvalidOperationException: ServiceMetadataBehavior 的 HttpsGetEnabled 屬性設置為 True,而 HttpsGetUrl 屬性是相對地址,但沒有 https 基址。請提供 https 基址或將 HttpsGetUrl 設置為絕對地址。]
   System.ServiceModel.Description.ServiceMetadataBehavior.EnsureGetDispatcher(ServiceHostBase host, ServiceMetadataExtension mex, Uri url, String scheme) +5330817
   System.ServiceModel.Description.ServiceMetadataBehavior.CreateHttpGetEndpoints(ServiceDescription description, ServiceHostBase host, ServiceMetadataExtension mex) +89
   System.ServiceModel.Description.ServiceMetadataBehavior.ApplyBehavior(ServiceDescription description, ServiceHostBase host) +61
   System.ServiceModel.Description.ServiceMetadataBehavior.System.ServiceModel.Description.IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) +30
   System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +3276
   System.ServiceModel.ServiceHostBase.InitializeRuntime() +60
   System.ServiceModel.ServiceHostBase.OnBeginOpen() +27
   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +50
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +206
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +651

[ServiceActivationException: 由於編譯過程中出現異常,無法激活服務“/Rights/RightService.svc”。異常消息為: ServiceMetadataBehavior 的 HttpsGetEnabled 屬性設置為 True,而 HttpsGetUrl 屬性是相對地址,但沒有 https 基址。請提供 https 基址或將 HttpsGetUrl 設置為絕對地址。。]
   System.Runtime.AsyncResult.End(IAsyncResult result) +688590
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234
   System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context) +24
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100

   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75




解決辦法:

      <serviceBehaviors>
         <behavior>
           <!-- 為避免泄漏元數據信息,請在部署前將以下值設置為 false -->
           <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
           <!-- 要接收故障異常詳細信息以進行調試,請將以下值設置為 true。在部署前設置為 false 以避免泄漏異常信息 -->
           <serviceDebug includeExceptionDetailInFaults="true"/>
         </behavior>
       
       </serviceBehaviors>





httpsGetEnabled="true"/ 改為:httpsGetEnabled="false"/ 即可。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM