共用方式為


針對 Visual Studio 的 Web Deploy 問題進行疑難解答

適用於: 因特網資訊服務

本文可協助您針對嘗試從 Visual Studio 發佈至未透過 Web Deploy 正確設定的伺服器時發生的一系列錯誤進行疑難解答。 雖然本文是針對特定產品版本所撰寫,但概念也可以套用至較新的版本。

若要收集下列螢幕快照和錯誤,請在Visual Studio 2010 SP1 中使用新的 ASP.Net MVC 3 專案。 目的地伺服器是 Windows Server 2008 R2 SP1 與 Internet Information Services (IIS) 的全新安裝。 未完成其他設定。

無法連線到伺服器

您可能會遇到的第一個錯誤看起來會像 Visual Studio 輸出視窗中的下列螢幕快照。 為了改善可讀性,螢幕快照下方提供訊息的全文:

顯示 Visual Studio 中 [錯誤清單] 輸出的螢幕快照。

Web deployment task failed.(Could not connect to the destination computer ("deployserver").On the destination computer, make sure that Web Deploy is installed and that the required process("The Web Management Service") is started.)
This error indicates that you cannot connect to the server. Make sure the service URL is correct,firewall and network settings on this computer and on the server computer are configured properly,and the appropriate services have been started on the server.
Error details:
Could not connect to the destination computer ("deployserver"). On the destination computer,
make sure that Web Deploy is installed and that the required process
("The Web Management Service") is started.
Unable to connect to the remote server
A connection attempt failed because the connected party did not properly respond after a period
of time, or established connection failed because connected host has failed to respond 1.1.1.1:8172

此錯誤中醒目提示的文字 (和下列其他錯誤) 是了解問題本質的關鍵。 Web Deploy 未從伺服器取得回復,因此 Visual Studio 無法區分數個可能的原因。 因此,它會提供要嘗試的項目清單。

是否已安裝 Web 管理服務?

在 IIS 伺服器上,開啟 [Internet Information Services (IIS) Manager ],然後選取電腦名稱節點。 在 [ 功能] 檢視 中,向下卷動至 [ 管理] 區段,並尋找下列圖示:

顯示 IIS 管理員許可權圖示、IIS 管理員用戶圖示和管理服務圖示的螢幕快照。

如果沒有,您必須透過 [ 新增角色服務 ] 對話框來安裝管理服務。 您也可以從 [ 產品 ] 索引標籤透過 Web Platform Installer 進行安裝。選取左欄中的 [伺服器 ],然後選 取 [IIS:管理服務]

注意事項

安裝管理服務之後,您必須啟動它,因為它不會自動啟動。 若要這樣做,請按兩下 管理服務 圖示。 顯示 [管理服務] 窗格之後,請在右側的 [動作] 窗格中選取 [啟動]。

服務 URL 是否正確?

根據預設,Web 管理服務會接聽埠 8172,但可以變更。 若要檢查所使用的埠,最簡單的方式是如上所述開啟 [管理服務] 窗格,並查看 Connections 一節中的IP和埠資訊。 如果埠已變更為 8172 以外的埠,您必須確保允許新的埠通過防火牆,並更新 Visual Studio 發佈設定中的服務 URL 以使用新的埠。

(403) 禁止

安裝 Web 管理服務之後,Visual Studio 可能會顯示下列錯誤:

顯示 Visual Studio 中 [錯誤清單] 畫面的螢幕快照。

Web deployment task failed.(Could not connect to the destination computer ("deployserver") using
the specified process ("The Web Management Service") because the server did not respond.
Make sure that the process ("The Web Management Service") is started on the destination computer.)
Could not connect to the destination computer ("deployserver") using the specified process
("The Web Management Service") because the server did not respond. Make sure that the process
("The Web Management Service") is started on the destination computer.
The remote server returned an error: (403) Forbidden.

此訊息有點誤導。 它指出伺服器未回應,但 403 錯誤指出 Web Deploy 可以連絡伺服器,但要求已主動遭到拒絕。 Web 管理服務的 HTTP 記錄檔可協助確認要求已送達伺服器,並提供失敗的實際要求詳細數據。 根據預設,您可以在 %SystemDrive%\Inetpub\logs\WMSvc 找到此記錄檔。 如同其他 IIS 記錄,數據不會立即寫入記錄檔,因此您可能必須等候幾分鐘才能看到要求,或重新啟動 Web 管理服務來排清記錄。

在記錄檔中 WMSVC ,上述錯誤看起來如下所示:

2011-06-02 17:59:05 192.168.0.211 POST /msdeploy.axd site=default%20web%20site 8172 - 192.168.0.203 - 403 6 5 1669

記錄 6 檔中的 後面 403 的 是子狀態代碼,表示IP位址遭到拒絕。 您可以在 IIS 中的 HTTP 狀態代碼找到 IIS 狀態和子狀態代碼的完整清單。

管理服務是否設定為允許遠端連線?

這是 403.6 回應的最可能原因。 按兩下 [管理服務] 圖示,並確認已核取 [啟用遠端 Connections]。 您必須停止服務才能進行變更,因此請務必在完成時重新啟動。

顯示 [管理服務] 對話框的螢幕快照。

是否允許 Web 管理服務通過 Windows 防火牆?

當您在伺服器上安裝 Web 管理服務時,輸入防火牆規則會命名為 Web Management Service (HTTP 流量) 。 移至 [啟動>具有進階安全性的>Windows 防火牆] 以確認已啟用此規則。 選 取 [輸入規則 ],然後在列表中尋找 Web 管理 規則。 應該為所有配置檔啟用此功能。

如果您使用第三方防火牆,您必須確保允許埠 8172 上的輸入連線。

是否已為管理服務設定IP限制?

您可能會收到 403 錯誤的另一個常見原因是管理服務已設定為拒絕用戶端的 IP。 根據預設,只要允許遠端連線,它就會設定為允許所有IP。 您可以按下 管理服務 圖示來檢查IP限制。 任何已設定的IP限制規則都位於[IPv4 位址限制] 頁面底部。

(404) 找不到

顯示 Visual Studio 中 [錯誤清單] 頁面的螢幕快照。錯誤詳細數據在焦點中。

Web deployment task failed.(Could not connect to the destination computer ("deployserver").
On the destination computer, make sure that Web Deploy is installed and that the required process
("The Web Management Service") is started.
The requested resource does not exist, or the requested URL is incorrect.
Error details: Could not connect to the destination computer ("deployserver").
On the destination computer, make sure that Web Deploy is installed and that the required process
("The Web Management Service") is started.
The remote server returned an error: (404) Not Found.

404 錯誤表示 Web Deploy 能夠連絡伺服器上的 Web 管理服務,但找不到所需的專案。 第一件事是確認 Web Deploy 嘗試連線的資源。 如果您在目的地伺服器的 %SystemDrive%\Inetpub\logs\WMSvc 底下查看 Web 管理服務記錄,您會在記錄中 WMSVC 看到如下所示的專案:

2011-05-12 15:21:50 192.168.0.211 POST /msdeploy.axd site=default%20web%20site 8172 - 192.168.0.203 - 404 7 0 1606

Msdeploy.axd 是 Web Deploy 要求的處理程式。

是否已安裝 Web Deploy?

您可以移至 [ 程式和功能 ] 控制面板,並在已安裝的程式清單中尋找 Microsoft Web Deploy 2.0 ,以確認是否已安裝 Web Deploy。 如果不存在,您可以移至 [ 產品 ] 索引標籤,透過Web Platform Installer 進行安裝。它列為 Web 部署工具 2.1。 您也應該確定 Web Deployment Agent​ Service (MsDepSvc) 正在執行。

是否已安裝 Web 部署處理程式?

如果已安裝 Web Deploy,但您仍然收到此錯誤,請確定已安裝 Web Deploy 中的 IIS 7 Deployment Handler 功能。 在 [ 程式和功能] 控制面板中,尋找 [Microsoft Web Deploy 2.0],以滑鼠右鍵按兩下並選取 [ 變更]。 在出現的精靈中,選取第一頁上的 [ 下一步 ],然後在第二頁選取 [ 變更 ]。 新增 IIS 7 Deployment Handler 及其下的所有專案。

顯示 [Microsoft Web Deploy 2 dot 0 安裝程式] 對話框的螢幕快照。Web Deployment Framework 會反白顯示。

選取 [下一步 ] 以完成精靈。 進行這項變更之後,您必須重新啟動 Web 管理服務。

(401) 未經授權

正確設定 Web Deploy 和 Web Management Service 之後,您必須設定委派規則,以允許使用者更新內容。 針對許可權問題,您可能會在 Visual Studio 中看到數個不同的錯誤。 例如:

顯示 Visual Studio 中 [錯誤清單] 的螢幕快照,其中顯示許可權問題錯誤。

Web deployment task failed.(Connected to the destination computer ("deployserver")
using the Web Management Service, but could not authorize.
Make sure that you are using the correct user name and password, that the site you are connecting
to exists, and that the credentials represent a user who has permissions to access the site.
Make sure the site name, user name, and password are correct. If the issue is not resolved,
please contact your local or server administrator.
Error details:
Connected to the destination computer ("deployserver") using the Web Management Service,
but could not authorize. Make sure that you are using the correct user name and password,
that the site you are connecting to exists, and that the credentials represent a user who
has permissions to access the site.
The remote server returned an error: (401) Unauthorized.

在 WMSvc 記錄檔中,您可以看到下列訊息:

2011-05-12 15:50:12 192.168.0.211 POST /msdeploy.axd site=default%20web%20site 8172 - 192.168.0.203 - 401 2 5 1653
2011-05-12 15:50:12 192.168.0.211 POST /msdeploy.axd site=default%20web%20site 8172 user1 192.168.0.203 - 401 1 1326 124

Visual Studio 輸出中醒目提示的 http 狀態是拒絕存取錯誤。 錯誤記錄檔中醒目提示的 win32 狀態會對應至「登入失敗:未知的使用者名稱或密碼錯誤」,因此這是簡單的登入失敗。 如果使用者已通過驗證,但沒有發佈所需的許可權,記錄項目看起來會像下列專案:

2011-05-12 15:55:38 192.168.0.211 POST /msdeploy.axd site=default%20web%20site 8172 - 192.168.0.203 - 401 2 5 0

若要允許此使用者發佈,您必須依照設定 Web 部署處理程式中的指示設定委派。

作業未獲授權

如果帳戶能夠登入,但尚未獲得發佈內容所需的許可權,您可以看到下列錯誤訊息:

顯示 Visual Studio 中 [錯誤清單] 頁面的螢幕快照,其中顯示與用戶權力相關的錯誤。

Web deployment task failed. (Unable to perform the operation ("Create Directory")  for the specified
directory ("bin"). This can occur if the server administrator has not authorized this operation for
the user credentials you are using.

記錄 WMSvc 會顯示這些要求的 HTTP 200 回應。 幸運的是,Web Deploy 2.1 也會將資訊寫入 Microsoft Web Deploy 服務記錄檔。 若要檢視它,請選 事件檢視器 ([本機) >應用程式和服務記錄>Microsoft Web Deploy]

顯示 [事件檢視器] 功能表的螢幕快照。Microsoft Web Deploy 已反白顯示。

針對此特定錯誤,事件記錄檔包含 (為了簡潔而截斷的額外詳細數據) :

User: DEPLOYSERVER\User1
Client IP: 192.168.0.203
Content-Type: application/msdeploy
Version: 8.0.0.0
MSDeploy.VersionMin: 7.1.600.0
MSDeploy.VersionMax: 7.1.1070.1
MSDeploy.Method: Sync
MSDeploy.RequestId: 50de0746-f10d-4640-9b3d-4ba773520e38
MSDeploy.RequestCulture: en-US
MSDeploy.RequestUICulture: en-US
Skip: objectName="^configProtectedData$"
Provider: auto, Path: 
Tracing deployment agent exception. Request ID '50de0746-f10d-4640-9b3d-4ba773520e38'. Request Timestamp: '5/12/2011 9:18:12 AM'. Error Details:
Microsoft.Web.Deployment.DeploymentDetailedUnauthorizedAccessException: Unable to perform the operation ("Create Directory")
for the specified directory ("C:\inetpub\wwwroot\bin"). This can occur if the server administrator has not authorized this
operation for the user credentials you are using.
---> Microsoft.Web.Deployment.DeploymentException: The error code was 0x80070005. ---> System.UnauthorizedAccessException:
Access to the path 'C:\inetpub\wwwroot\bin' is denied.
   at Microsoft.Web.Deployment.Win32Native.RaiseIOExceptionFromErrorCode(Win32ErrorCode errorCode, String maybeFullPath)
   at Microsoft.Web.Deployment.DirectoryEx.CreateDirectory(String path)
   at Microsoft.Web.Deployment.DirPathProvider.CreateDirectory(String fullPath, DeploymentObject source)
   at Microsoft.Web.Deployment.DirPathProvider.Add(DeploymentObject source, Boolean whatIf)
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---

此訊息會告訴您必須針對此特定錯誤授與許可權的位置。 您可能也會在 Visual Studio 中看到下列權限錯誤:

顯示 Visual Studio 中 [錯誤清單] 頁面的螢幕快照,其中焦點為許可權錯誤。

Web deployment task failed.((5/12/2011 11:31:41 AM) An error occurred when the request was processed on the remote computer.)

(5/12/2011 11:31:41 AM) An error occurred when the request was processed on the remote computer.
The server experienced an issue processing the request. Contact the server administrator for more information.

這個特定錯誤並不會提供您太多功能,但如果您在 事件檢視器 中查看 Web Deploy 錯誤記錄檔,圖片會變得更清楚。

User: DEPLOYSERVER\User1
Client IP: 192.168.0.203
Content-Type: application/msdeploy
Version: 8.0.0.0
MSDeploy.VersionMin: 7.1.600.0
MSDeploy.VersionMax: 7.1.1070.1
MSDeploy.Method: Sync
MSDeploy.RequestId: 63b2f3d1-1817-444f-8280-9fa4f6f85d53
MSDeploy.RequestCulture: en-US
MSDeploy.RequestUICulture: en-US
Skip: objectName="^configProtectedData$"
Provider: auto, Path: 
Tracing deployment agent exception. Request ID '63b2f3d1-1817-444f-8280-9fa4f6f85d53'. Request Timestamp: '5/12/2011 9:31:41 AM'. Error Details:
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
   at System.Security.AccessControl.Win32.SetSecurityInfo(ResourceType type, String name, SafeHandle handle, SecurityInfos securityInformation, SecurityIdentifier owner, SecurityIdentifier group, GenericAcl sacl, GenericAcl dacl)
   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)
   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, AccessControlSections includeSections, Object exceptionContext)
   at Microsoft.Web.Deployment.FileSystemSecurityEx.Persist(String path)
   at Microsoft.Web.Deployment.SetAclProvider.Add(DeploymentObject source, Boolean whatIf)
   at Microsoft.Web.Deployment.DeploymentObject.Update(DeploymentObject source, DeploymentSyncContext syncContext)
   at Microsoft.Web.Deployment.DeploymentSyncContext.HandleUpdate(DeploymentObject destObject, DeploymentObject sourceObject)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)
   at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)

從此輸出中,我們可以看到 User1 沒有設定安全性信息的許可權。 在此情況下,用戶沒有內容的「修改許可權」。 將「變更許可權」授與內容可解決問題。

其他人

如果您在成功發佈 .NET 4.0 應用程式之後無法流覽它,可能是 .NET 4.0 尚未向 IIS 正確註冊。 其他徵兆是已安裝 .NET 4.0,但 IIS 中沒有 .NET 4.0 應用程式集區或處理程序對應。 這會在安裝 IIS 之前安裝 .NET 4.0 時發生。 若要修正此問題,請啟動提升許可權的命令提示字元並執行此命令:

%systemdrive%\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -iru

其他相關資訊