天天看點

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

前言

什麼人适合閱讀本文?

   如果你想利用postman進行遠端調試你的WCF服務或者遇到Unable to start debugging on the web server. You do not have permissions to debug the web server process. You need to either be running as...的問題。

本地調式問題

在VS2019中檢視調試的配置:

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

擷取調式的虛拟路徑:

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

單擊IIS調試:

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

單擊字尾為svc的檔案

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

出現以下界面說明配置無誤,在URL欄中擷取服務位址

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

此時web服務不要關掉,即要確定VS處于調試狀态,并且你已經設定了斷點:

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

打開Postman,建立一個新的連接配接,單擊Send:

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

成功進入斷點處:

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

遠端調試問題

首先要釋出一個IIS服務,且要求防火牆允許跨域通路(見文章:Win10讓區域網路内其他電腦通過IP通路網站的方法)

這是我建立好的站點(實體路徑中要包含web.config):

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~
【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

如下,web服務的通路沒有任何問題

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

然後回到VS2019,在Debug Properties中進行如下設定:

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

然後再按照本地服務那樣遠端調試即可

異常問題

首先檢查web.config的配置,web.config标準跨域通路配置如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2"/>
    <httpRuntime targetFramework="4.5.2"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="MapTemplateWCF.MapService" behaviorConfiguration="servicebehavior">
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="" name="endpoint1" contract="MapTemplateWCF.IMapService"
          behaviorConfiguration="NewBehavior0"/>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="NewBehavior0">
          <enableWebScript/>
          <webHttp/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="servicebehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
         <add name="Access-Control-Allow-Origin" value="*"/>
      </customHeaders>
    </httpProtocol>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>
           

如果Debug Properties設定後啟動調試出現對話框,裡面内容顯示:Unable to start debugging on the web server. You do not have permissions to debug the web server process. You need to either be running as...

是權限的問題,首先設定IIS的權限,然後再對VS2019做更改:

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

確定所有使用者的授權是完全控制

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

最後關閉VS2019,右擊以管理者的權限運作,問題即可得解決。

參考資料

1. stackoverflow :Unable to start debugging on the web server using visual studio 2012. https://stackoverflow.com/questions/24082215/unable-to-start-debugging-on-the-web-server-using-visual-studio-2012

掃碼關注我擷取更多程式設計知識,共同進步吧!~

【Postman+WCF+Visual Studio 2019】遠端+本地調式以及IIS釋出服務,Unable to start debugging on the web server. You do前言本地調式問題遠端調試問題異常問題參考資料掃碼關注我擷取更多程式設計知識,共同進步吧!~

繼續閱讀