日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

core部署iis的 调试net_远程调试远程 IIS 计算机上的 ASP.NET Core - Visual Studio | Microsoft Docs...

發(fā)布時(shí)間:2025/3/21 75 豆豆
生活随笔 收集整理的這篇文章主要介紹了 core部署iis的 调试net_远程调试远程 IIS 计算机上的 ASP.NET Core - Visual Studio | Microsoft Docs... 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在 Visual Studio 中遠(yuǎn)程調(diào)試遠(yuǎn)程 IIS 計(jì)算機(jī)上的 ASP.NET CoreRemote Debug ASP.NET Core on a Remote IIS Computer in Visual Studio

05/06/2020

本文內(nèi)容

若要調(diào)試已部署到 IIS 的 ASP.NET Core 應(yīng)用程序,請(qǐng)?jiān)诓渴饝?yīng)用的計(jì)算機(jī)上安裝并運(yùn)行遠(yuǎn)程工具,然后從 Visual Studio 附加到正在運(yùn)行的應(yīng)用。To debug an ASP.NET Core application that has been deployed to IIS, install and run the remote tools on the computer where you deployed your app, and then attach to your running app from Visual Studio.

本指南說(shuō)明如何設(shè)置和配置 Visual Studio ASP.NET Core,將其部署到 IIS,并從 Visual Studio 附加遠(yuǎn)程調(diào)試器。This guide explains how to set up and configure a Visual Studio ASP.NET Core, deploy it to IIS, and attach the remote debugger from Visual Studio. 若要遠(yuǎn)程調(diào)試 ASP.NET 4.5.2,請(qǐng)參閱遠(yuǎn)程調(diào)試 IIS 計(jì)算機(jī)上的 ASP.NET。也可以使用 Azure 在 IIS 上進(jìn)行部署和調(diào)試。You can also deploy and debug on IIS using Azure. 對(duì)于 Azure 應(yīng)用服務(wù),可以使用 Snapshot Debugger 或通過(guò)從服務(wù)器資源管理器附加調(diào)試器,在預(yù)先配置的 IIS 實(shí)例和遠(yuǎn)程調(diào)試器上輕松進(jìn)行部署和調(diào)試。For Azure App Service, you can easily deploy and debug on a preconfigured instance of IIS and the remote debugger using either the Snapshot Debugger or by attaching the debugger from Server Explorer.

先決條件Prerequisites

需要安裝 Visual Studio 2019 才能執(zhí)行本文所述的步驟。Visual Studio 2019 is required to follow the steps shown in this article.

需要安裝 Visual Studio 2017 才能執(zhí)行本文所述的步驟。Visual Studio 2017 is required to follow the steps shown in this article.

這些過(guò)程已在以下服務(wù)器配置上進(jìn)行了測(cè)試:These procedures have been tested on these server configurations:

Windows Server 2012 R2 和 IIS 8Windows Server 2012 R2 and IIS 8

Windows Server 2016 和 IIS 10Windows Server 2016 and IIS 10

Windows Server 2019 和 IIS 10Windows Server 2019 and IIS 10

網(wǎng)絡(luò)要求Network requirements

不支持在通過(guò)代理連接的兩臺(tái)計(jì)算機(jī)之間進(jìn)行調(diào)試。Debugging between two computers connected through a proxy is not supported. 不建議通過(guò)高延遲或低帶寬連接(例如撥號(hào) Internet)或在跨國(guó)家/地區(qū)的 Internet 上進(jìn)行調(diào)試,否則可能會(huì)導(dǎo)致調(diào)試失敗或速度過(guò)慢。Debugging over a high latency or low-bandwidth connection, such as dialup Internet, or over the Internet across countries is not recommended and may fail or be unacceptably slow. 有關(guān)要求的完整列表,請(qǐng)參閱要求。For a complete list of requirements, see Requirements.

應(yīng)用已在 IIS 中運(yùn)行?App already running in IIS?

本文包含有關(guān)在 Windows Server 上設(shè)置 IIS 的基本配置以及從 Visual Studio 部署應(yīng)用的步驟。This article includes steps on setting up a basic configuration of IIS on Windows server and deploying the app from Visual Studio. 這些步驟可確保服務(wù)器安裝了必需的組件,應(yīng)用可以正常運(yùn)行,以及你已經(jīng)準(zhǔn)備好進(jìn)行遠(yuǎn)程調(diào)試。These steps are included to make sure that the server has required components installed, that the app can run correctly, and that you are ready to remote debug.

如果應(yīng)用正在 IIS 中運(yùn)行,你只想下載遠(yuǎn)程調(diào)試器并啟動(dòng)調(diào)試,請(qǐng)轉(zhuǎn)到在 Windows Server 上下載并安裝遠(yuǎn)程工具。If your app is running in IIS and you just want to download the remote debugger and start debugging, go to Download and Install the remote tools on Windows Server.

如果需要幫助確保在 IIS 中正確設(shè)置、部署和運(yùn)行應(yīng)用,以便進(jìn)行調(diào)試,請(qǐng)按照本主題中的所有步驟進(jìn)行操作。If you want help to make sure that your app is set up, deployed, and running correctly in IIS so that you can debug, follow all the steps in this topic.

在 Visual Studio 計(jì)算機(jī)上創(chuàng)建 ASP.NET Core 應(yīng)用程序Create the ASP.NET Core application on the Visual Studio computer

創(chuàng)建新的 ASP.NET Core Web 應(yīng)用呈現(xiàn)。Create a new ASP.NET Core web application.

在 Visual Studio 2019 中,鍵入 Ctrl + Q 打開(kāi)搜索框,鍵入“asp.net”,選擇“模板”,然后選擇“創(chuàng)建新的 ASP.NET Core Web 應(yīng)用程序” 。In Visual Studio 2019, type Ctrl + Q to open the search box, type asp.net, choose Templates, then choose Create new ASP.NET Core Web Application. 在出現(xiàn)的對(duì)話框中,將項(xiàng)目命名為“MyASPApp”,然后選擇“創(chuàng)建” 。In the dialog box that appears, name the project MyASPApp, and then choose Create. 接下來(lái),選擇“Web 應(yīng)用程序(模型-視圖-控制器)”,然后選擇“創(chuàng)建” 。Next, choose Web Application (Model-View-Controller), and then choose Create.

在 Visual Studio 2017 中,選擇“文件”>“新建”>“項(xiàng)目”,然后選擇“Visual C#”>“Web”>“ASP.NET Core Web 應(yīng)用程序” 。In Visual Studio 2017, choose File > New > Project, then select Visual C# > Web > ASP.NET Core Web Application. 在“ASP.NET Core 模板”部分中,選擇“Web 應(yīng)用程序(模型-視圖-控制器)”。In the ASP.NET Core templates section, select Web Application (Model-View-Controller). 確保選擇了 ASP.NET Core 2.1,未選擇“啟用 Docker 支持”,并且“身份驗(yàn)證”設(shè)置為“無(wú)身份驗(yàn)證” 。Make sure that ASP.NET Core 2.1 is selected, that Enable Docker Support is not selected and that Authentication is set to No Authentication. 將項(xiàng)目命名為“MyASPApp”。Name the project MyASPApp.

打開(kāi) About.cshtml.cs 文件,并在 OnGet 方法中設(shè)置斷點(diǎn)(在較舊的模板中,改為打開(kāi) HomeController.cs 并在 About() 方法中設(shè)置斷點(diǎn))。Open the About.cshtml.cs file and set a breakpoint in the OnGet method (in older templates, open HomeController.cs instead and set the breakpoint in the About() method).

在 Windows Server 上安裝和配置 IISInstall and Configure IIS on Windows Server

以下步驟僅顯示 IIS 的基本配置。These steps show only a basic configuration of IIS. For more in-depth information or to install to a Windows Desktop machine, see Publishing to IIS or IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5.

對(duì)于 Windows Server 操作系統(tǒng),通過(guò)“管理”鏈接或“服務(wù)器管理器”中的“儀表板”鏈接使用“添加角色和功能”向?qū)?。For Windows Server operating systems, use the Add Roles and Features wizard via the Manage link or the Dashboard link in Server Manager. 在“服務(wù)器角色”步驟中,選中“Web 服務(wù)器(IIS)”框 。On the Server Roles step, check the box for Web Server (IIS).

在“角色服務(wù)”步驟中,選擇所需 IIS 角色服務(wù),或接受提供的默認(rèn)角色服務(wù) 。On the Role services step, select the IIS role services you desire or accept the default role services provided. 如果要使用發(fā)布設(shè)置和 Web 部署啟用部署,請(qǐng)確保選中“IIS 管理腳本和工具” 。If you want to enable deployment using publish settings and Web Deploy, make sure that IIS Management Scripts and Tools is selected.

繼續(xù)執(zhí)行確認(rèn)步驟,安裝 Web 服務(wù)器角色和服務(wù)。Proceed through the confirmation steps to install the web server role and services. 安裝 Web 服務(wù)器 (IIS) 角色后無(wú)需重啟服務(wù)器/IIS。A server/IIS restart is not required after installing the Web Server (IIS) role.

更新 Windows Server 上的瀏覽器安全設(shè)置Update browser security settings on Windows Server

如果在 Internet Explorer 中啟用了“增強(qiáng)的安全配置”(默認(rèn)情況下已啟用),則可能需要將某些域添加為受信任的站點(diǎn),以便下載某些 Web 服務(wù)器組件。If Enhanced Security Configuration is enabled in Internet Explorer (it is enabled by default), then you may need to add some domains as trusted sites to enable you to download some of the web server components. 通過(guò)轉(zhuǎn)到“Internet 選項(xiàng)”>“安全性”>“受信任的站點(diǎn)”>“站點(diǎn)”來(lái)添加受信任的站點(diǎn)。Add the trusted sites by going to Internet Options > Security > Trusted Sites > Sites. 添加以下域。Add the following domains.

microsoft.commicrosoft.com

go.microsoft.comgo.microsoft.com

download.microsoft.comdownload.microsoft.com

iis.netiis.net

下載軟件時(shí),可能會(huì)收到授權(quán)加載各種網(wǎng)站腳本和資源的請(qǐng)求。When you download the software, you may get requests to grant permission to load various web site scripts and resources. 其中一些資源不是必需的,但為了簡(jiǎn)化此過(guò)程,請(qǐng)?jiān)诔霈F(xiàn)提示時(shí)單擊“添加”。Some of these resources are not required, but to simplify the process, click Add when prompted.

在 Windows Server 上安裝 ASP.NET CoreInstall ASP.NET Core on Windows Server

在托管系統(tǒng)上安裝 .NET Core 托管捆綁包。Install the .NET Core Hosting Bundle on the hosting system. 捆綁包可安裝 .NET Core 運(yùn)行時(shí)、.NET Core 庫(kù)和 ASP.NET Core 模塊。The bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. 有關(guān)更深入的說(shuō)明,請(qǐng)參閱發(fā)布到 IIS。For more in-depth instructions, see Publishing to IIS.

備注

如果系統(tǒng)沒(méi)有 Internet 連接,請(qǐng)先獲取并安裝 Microsoft Visual C++ 2015 Redistributable,再安裝 .NET Core Windows Server 托管捆綁包。If the system doesn't have an Internet connection, obtain and install the

重啟系統(tǒng)(或在命令提示符處依次執(zhí)行“net stop was /y”和“net start w3svc”,了解系統(tǒng)路徑的更改) 。Restart the system (or execute net stop was /y followed by net start w3svc from a command prompt to pick up a change to the system PATH).

選擇部署選項(xiàng)Choose a deployment option

如果需要幫助將應(yīng)用部署到 IIS,請(qǐng)考慮以下選項(xiàng):If you need help to deploy the app to IIS, consider these options:

通過(guò)在 IIS 中創(chuàng)建發(fā)布設(shè)置文件并在 Visual Studio 中導(dǎo)入設(shè)置來(lái)進(jìn)行部署。Deploy by creating a publish settings file in IIS and importing the settings in Visual Studio. 在某些情況下,這是一種快速部署應(yīng)用的方法。In some scenarios, this is a fast way to deploy your app. 當(dāng)你創(chuàng)建發(fā)布設(shè)置文件時(shí),系統(tǒng)會(huì)在 IIS 中自動(dòng)設(shè)置權(quán)限。When you create the publish settings file, permissions are automatically set up in IIS.

通過(guò)發(fā)布到本地文件夾并使用首選方法將輸出復(fù)制到 IIS 上準(zhǔn)備就緒的應(yīng)用文件夾來(lái)進(jìn)行部署。Deploy by publishing to a local folder and copying the output by a preferred method to a prepared app folder on IIS.

(可選)使用發(fā)布設(shè)置文件進(jìn)行部署(Optional) Deploy using a publish settings file

可以使用此選項(xiàng)創(chuàng)建一個(gè)發(fā)布設(shè)置文件,并將其導(dǎo)入到 Visual Studio 中。You can use this option create a publish settings file and import it into Visual Studio.

備注

此部署方法使用 Web 部署,必須安裝在服務(wù)器上。This deployment method uses Web Deploy, which must be installed on the server. 如果要手動(dòng)配置 Web 部署,而不是導(dǎo)入設(shè)置,則可以安裝 Web 部署 3.6,而不是用于托管服務(wù)器的 Web 部署 3.6。If you want to configure Web Deploy manually instead of importing the settings, you can install Web Deploy 3.6 instead of Web Deploy 3.6 for Hosting Servers. 但是,如果手動(dòng)配置 Web 部署,則需要確保使用正確的值和權(quán)限配置服務(wù)器上的應(yīng)用文件夾(請(qǐng)參閱配置 ASP.NET 網(wǎng)站)。However, if you configure Web Deploy manually, you will need to make sure that an app folder on the server is configured with the correct values and permissions (see Configure ASP.NET Web site).

配置 ASP.NET Core 網(wǎng)站Configure the ASP.NET Core web site

在 IIS 管理器左窗格的“連接”下,選擇“應(yīng)用程序池” 。In IIS Manager, in the left pane under Connections, select Application Pools. 打開(kāi) DefaultAppPool,將“.NET CLR 版本”設(shè)置為“無(wú)托管代碼” 。Open DefaultAppPool and set the .NET CLR version to No Managed Code. ASP.NET Core 需要執(zhí)行此操作。This is required for ASP.NET Core. 默認(rèn)網(wǎng)站使用 DefaultAppPool。The Default Web Site uses the DefaultAppPool.

停止并重新啟動(dòng) DefaultAppPool。Stop and restart the DefaultAppPool.

在 Windows Server 上安裝和配置用于宿主服務(wù)器的 Web 部署Install and configure Web Deploy for Hosting Servers on Windows Server

用于托管服務(wù)器的 Web 部署 3.6 提供額外的配置功能,可實(shí)現(xiàn)從 UI 創(chuàng)建發(fā)布設(shè)置文件。Web Deploy 3.6 for Hosting Servers provides additional configuration features that enable the creation of the publish settings file from the UI.

如果已在 Windows Server 上安裝 Web 部署,請(qǐng)使用“控制面板” > “程序” > “卸載程序”將其卸載。If you have Web Deploy already installed on Windows Server, uninstall it using Control Panel > Programs > Uninstall a Program.

接下來(lái),在 Windows 服務(wù)器上安裝用于托管服務(wù)器的 Web 部署 3.6。Next, install Web Deploy 3.6 for Hosting Servers on Windows Server.

要安裝用于托管服務(wù)器的 Web 部署,請(qǐng)使用 Web 平臺(tái)安裝程序 (WebPI)。To install Web Deploy for Hosting Servers, use the Web Platform Installer (WebPI). (要從 IIS 查找 Web 平臺(tái)安裝程序鏈接,請(qǐng)選擇服務(wù)器管理器左側(cè)窗格中的“IIS”。(To find the Web Platform Installer link from IIS, select IIS in the left pane of Server Manager. 在服務(wù)器窗格中,右鍵單擊服務(wù)器并選擇“Internet Information Services (IIS)管理器”。In the server pane, right-click the server and select Internet Information Services (IIS) Manager. 然后,在“操作”窗口中,使用“獲取新的 Web 平臺(tái)組件”連接 。)你還可以從下載獲取 Web 平臺(tái)安裝程序 (WebPI)。Then use the Get New Web Platform Components link in the Actions window.) You can also obtain the Web Platform Installer (WebPI) from downloads.

在 Web 平臺(tái)安裝程序中,在“應(yīng)用程序”選項(xiàng)卡中查找“用于托管服務(wù)器的 Web 部署 3.6”。In the Web Platform Installer, you find Web Deploy 3.6 for Hosting Servers in the Applications tab.

如果尚未安裝“IIS 管理腳本和工具”,請(qǐng)立即安裝。If you did not already install IIS Management Scripts and Tools, install it now.

轉(zhuǎn)到“選擇服務(wù)器角色” > “Web 服務(wù)器(IIS)” > “管理工具”,然后選擇“IIS 管理腳本和工具”角色,點(diǎn)擊“下一步”,然后安裝角色 。Go to Select server roles > Web Server (IIS) > Management Tools, and then select the IIS Management Scripts and Tools role, click Next, and then install the role.

需要腳本和工具來(lái)生成發(fā)布設(shè)置文件。The scripts and tools are required to enable the generation of the publish settings file.

根據(jù)需要,打開(kāi)“控制面板”>“系統(tǒng)和安全”>“管理工具”>“服務(wù)”來(lái)驗(yàn)證 Web 部署是否正確運(yùn)行,然后確保:(Optional) Verify that Web Deploy is running correctly by opening Control Panel > System and Security > Administrative Tools > Services, and then make sure that:

“Web 部署代理服務(wù)”正在運(yùn)行(舊版本中的服務(wù)名稱不同)。Web Deployment Agent Service is running (the service name is different in older versions).

“Web 管理服務(wù)”正在運(yùn)行。Web Management Service is running.

如果某個(gè)代理服務(wù)未運(yùn)行,請(qǐng)重新啟動(dòng)“Web 部署代理服務(wù)”。If one of the agent services is not running, restart the Web Deployment Agent Service.

如果 Web 部署代理服務(wù)不存在,請(qǐng)轉(zhuǎn)到“控制面板”>“程序”>“卸載程序”,查找“Microsoft Web 部署 。If the Web Deployment Agent Service is not present at all, go to Control Panel > Programs > Uninstall a program, find Microsoft Web Deploy . 選擇“更改”安裝,并確保對(duì) Web 部署組件選擇“將安裝到本地驅(qū)動(dòng)器” 。Choose to Change the installation and make sure that you choose Will be installed to the local hard drive for the Web Deploy components. 完成更改安裝步驟。Complete the change installation steps.

在 Windows Server 上的 IIS 中創(chuàng)建發(fā)布設(shè)置文件Create the publish settings file in IIS on Windows Server

關(guān)閉并重新打開(kāi) IIS 管理控制臺(tái)以在 UI 中顯示更新的配置選項(xiàng)。Close and reopen the IIS Management Console to show updated configuration options in the UI.

在 IIS 中,右鍵單擊“默認(rèn)網(wǎng)站”,選擇“部署” > “配置 Web 部署發(fā)布” 。In IIS, right-click the Default Web Site, choose Deploy > Configure Web Deploy Publishing.

如果看不到“部署”菜單,請(qǐng)參閱前面的部分來(lái)驗(yàn)證 Web 部署是否正在運(yùn)行。If you don't see the Deploy menu, see the preceding section to verify that Web Deploy is running.

在“配置 Web 部署發(fā)布”對(duì)話框中,檢查設(shè)置。In the Configure Web Deploy Publishing dialog box, examine the settings.

單擊“設(shè)置”。Click Setup.

在“結(jié)果”面板中,輸出顯示已為指定用戶授予訪問(wèn)權(quán)限,并且已在對(duì)話框中顯示的位置生成了具有 .publishsettings 文件擴(kuò)展名的文件。In the Results panel, the output shows that access rights are granted to the specified user, and that a file with a .publishsettings file extension has been generated in the location shown in the dialog box.

publishUrl="https://myhostname:8172/msdeploy.axd"

msdeploySite="Default Web Site"

destinationAppUrl="http://myhostname:80/"

mySQLDBConnectionString=""

SQLServerDBConnectionString=""

profileName="Default Settings"

publishMethod="MSDeploy"

userName="myhostname\myusername" />

根據(jù) Windows Server 和 IIS 配置,可以在 XML 文件看到不同的值。Depending on your Windows Server and IIS configuration, you see different values in the XML file. 下面是有關(guān)所看到的值的一些詳細(xì)信息:Here are a few details about the values that you see:

publishUrl 屬性中引用的 msdeploy.axd 文件是 Web 部署動(dòng)態(tài)生成的 HTTP 處理程序文件。The msdeploy.axd file referenced in the publishUrl attribute is a dynamically generated HTTP handler file for Web Deploy. (用于測(cè)試目的,http://myhostname:8172 通常也適用。)(For testing purposes, http://myhostname:8172 generally works as well.)

publishUrl 端口設(shè)置為端口 8172,這是 Web 部署的默認(rèn)端口。The publishUrl port is set to port 8172, which is the default for Web Deploy.

destinationAppUrl 端口設(shè)置為端口 80,這是 IIS 部署的默認(rèn)端口。The destinationAppUrl port is set to port 80, which is the default for IIS.

如果使用主機(jī)名無(wú)法在 Visual Studio 中連接到遠(yuǎn)程主機(jī)(在后續(xù)步驟中),請(qǐng)測(cè)試 IP 地址以代替主機(jī)名。If you are unable to connect to the remote host in Visual Studio using the host name (in later steps), test the IP address in place of the host name.

備注

如果要發(fā)布到在 Azure VM 上運(yùn)行的 IIS,則必須在網(wǎng)絡(luò)安全組中打開(kāi) Web 部署和 IIS 端口。If you are publishing to IIS running on an Azure VM, you must open the Web Deploy and IIS ports in the Network Security group. 有關(guān)詳細(xì)信息,請(qǐng)參閱安裝和運(yùn)行 IIS。For detailed information, see Install and run IIS.

將此文件復(fù)制到運(yùn)行 Visual Studio 的計(jì)算機(jī)上。Copy this file to the computer where you are running Visual Studio.

在 Visual Studio 中導(dǎo)入發(fā)布設(shè)置并進(jìn)行部署Import the publish settings in Visual Studio and deploy

如果計(jì)算機(jī)上的 Visual Studio 中打開(kāi)有 ASP.NET 項(xiàng)目,則在該計(jì)算機(jī)的解決方案資源管理器中右鍵單擊該項(xiàng)目,然后選擇“發(fā)布”。On the computer where you have the ASP.NET project open in Visual Studio, right-click the project in Solution Explorer, and choose Publish.

如果先前配置了任何發(fā)布配置文件,則“發(fā)布”窗格會(huì)顯示。If you have previously configured any publishing profiles, the Publish pane appears. 點(diǎn)擊“新建配置文件”。Click Create new profile.

在“選取發(fā)布目標(biāo)”對(duì)話框中,點(diǎn)擊“導(dǎo)入配置文件” 。In the Pick a publish target dialog box, click Import Profile.

導(dǎo)航到上一節(jié)中創(chuàng)建的發(fā)布設(shè)置文件的位置。Navigate to the location of the publish settings file that you created in the previous section.

在“導(dǎo)入發(fā)布設(shè)置文件”對(duì)話框中,導(dǎo)航到在上一部分創(chuàng)建的配置文件并選擇該文件,然后單擊“打開(kāi)” 。In the Import Publish Settings File dialog, navigate to and select the profile that you created in the previous section, and click Open.

Visual Studio 開(kāi)始執(zhí)行部署過(guò)程,并且輸出窗口將顯示進(jìn)度和結(jié)果。Visual Studio begins the deployment process, and the Output window shows progress and results.

如果出現(xiàn)任何部署錯(cuò)誤,請(qǐng)單擊“設(shè)置”以編輯設(shè)置。If you get an any deployment errors, click Settings to edit settings. 修改設(shè)置,然后單擊“驗(yàn)證”以測(cè)試新設(shè)置。Modify settings and click Validate to test new settings. 如果找不到主機(jī)名,請(qǐng)嘗試“服務(wù)器”和“目標(biāo) URL”字段中的 IP 地址而不是主機(jī)名 。If the host name is not found, try the IP address instead of the host name in the Server and Destination URL fields.

應(yīng)用成功部署后,它應(yīng)自動(dòng)啟動(dòng)。After the app deploys successfully, it should start automatically. 如果在 Visual Studio 中無(wú)法啟動(dòng)應(yīng)用,請(qǐng)?jiān)?IIS 中啟動(dòng)應(yīng)用以驗(yàn)證其是否正常運(yùn)行。If the app does not start from Visual Studio, start the app in IIS to verify that it runs correctly. 對(duì)于 ASP.NET Core,還需要確保將 DefaultAppPool 的“應(yīng)用程序池”字段設(shè)置為“無(wú)托管代碼” 。For ASP.NET Core, you also need to make sure that the Application pool field for the DefaultAppPool is set to No Managed Code.

在“設(shè)置”對(duì)話框中,單擊“下一步”啟用調(diào)試,選擇“調(diào)試”配置,然后在“文件發(fā)布”選項(xiàng)下選擇“刪除目標(biāo)處的其他文件” 。In the Settings dialog box, enable debugging by clicking Next, choose a Debug configuration, and then choose Remove additional files at destination under the File Publish options.

重要

如果選擇發(fā)布配置,則在發(fā)布時(shí),需要在 web.config 文件中禁用調(diào)試。If you choose a Release configuration, you disable debugging in the web.config file when you publish.

單擊“保存”,然后重新發(fā)布應(yīng)用。Click Save and then republish the app.

(可選)通過(guò)發(fā)布到本地文件夾進(jìn)行部署(Optional) Deploy by publishing to a local folder

如果要使用 PowerShell、RoboCopy 將應(yīng)用復(fù)制到 IIS,或者要手動(dòng)復(fù)制文件,則可以使用此選項(xiàng)來(lái)部署應(yīng)用。You can use this option to deploy your app if you want to copy the app to IIS using PowerShell, RoboCopy, or you want to manually copy the files.

在 Windows Server 計(jì)算機(jī)上配置 ASP.NET Core 網(wǎng)站Configure the ASP.NET Core Web site on the Windows Server computer

打開(kāi) Windows 資源管理器并創(chuàng)建新文件夾 C:\Publish,稍后將在其中部署 ASP.NET Core 項(xiàng)目。Open Windows Explorer and create a new folder, C:\Publish, where you will later deploy the ASP.NET Core project.

如果尚未打開(kāi),請(qǐng)打開(kāi)“Internet Information Services (IIS) 管理器”。If it's not already open, open the Internet Information Services (IIS) Manager. (在服務(wù)器管理器的左窗格中,選擇“IIS”。(In the left pane of Server Manager, select IIS. 右鍵單擊服務(wù)器并選擇“Internet Information Services (IIS)管理器”。)Right-click the server and select Internet Information Services (IIS) Manager.)

在左窗格中的“連接”下,轉(zhuǎn)到“站點(diǎn)”。Under Connections in the left pane, go to Sites.

選擇“默認(rèn)網(wǎng)站”,選擇“基本設(shè)置”,然后將“物理路徑”設(shè)置為“C:\Publish”。Select the Default Web Site, choose Basic Settings, and set the Physical path to C:\Publish.

右鍵單擊“默認(rèn)網(wǎng)站” 節(jié)點(diǎn),然后選擇“添加應(yīng)用程序” 。Right-click the Default Web Site node and select Add Application.

將“別名”字段設(shè)置為“MyASPApp”,接受默認(rèn)應(yīng)用程序池 (DefaultAppPool),并將“物理路徑”設(shè)置“C:\Publish”。Set the Alias field to MyASPApp, accept the default Application Pool (DefaultAppPool), and set the Physical path to C:\Publish.

在“連接”下,選擇“應(yīng)用程序池”。Under Connections, select Application Pools. 打開(kāi)“DefaultAppPool”,然后將應(yīng)用程序池字段設(shè)置為“無(wú)托管代碼”。Open DefaultAppPool and set the Application pool field to No Managed Code.

右鍵單擊 IIS 管理器中的新站點(diǎn),選擇“編輯權(quán)限”,并確保 IUSR、IIS_IUSRS 或配置為訪問(wèn) Web 應(yīng)用的用戶是具有讀取和執(zhí)行權(quán)限的授權(quán)用戶。Right-click the new site in the IIS Manager, choose Edit Permissions, and make sure that IUSR, IIS_IUSRS, or the user configured for access to the web app is an authorized user with Read & Execute rights.

如果沒(méi)有看到其中任何一個(gè)用戶具有訪問(wèn)權(quán)限,請(qǐng)執(zhí)行相應(yīng)步驟將 IUSR 添加為具有讀取和執(zhí)行權(quán)限的用戶。If you don't see one of these users with access, go through steps to add IUSR as a user with Read & Execute rights.

通過(guò)從 Visual Studio 發(fā)布到本地文件夾來(lái)發(fā)布和部署應(yīng)用Publish and Deploy the app by publishing to a local folder from Visual Studio

還可以使用文件系統(tǒng)或其他工具發(fā)布和部署應(yīng)用。You can also publish and deploy the app using the file system or other tools.

在“解決方案資源管理器” 中,右鍵單擊項(xiàng)目節(jié)點(diǎn)并選擇“發(fā)布” (對(duì)于 Web Forms,選擇“發(fā)布 Web 應(yīng)用” )。In the Solution Explorer, right-click the project node and select Publish (for Web Forms, Publish Web App).

如果先前配置了任何發(fā)布配置文件,則“發(fā)布”窗格會(huì)顯示 。If you have previously configured any publishing profiles, the Publish pane appears. 單擊“新建配置文件” 。Click New profile.

在“發(fā)布” 對(duì)話框中,選擇“文件夾” ,單擊“瀏覽” ,然后創(chuàng)建一個(gè)新文件夾“C:\Publish” 。In the Publish dialog box, select Folder, click Browse, and create a new folder, C:\Publish.

對(duì)于 Web Forms 應(yīng)用,請(qǐng)?jiān)凇鞍l(fā)布”對(duì)話框中選擇“自定義” ,輸入配置文件名稱,然后選擇“確定” 。For a Web Forms app, choose Custom in the Publish dialog box, enter a profile name, and choose OK.

單擊下拉列表中的“創(chuàng)建配置文件” (默認(rèn)值為“發(fā)布” )。Click Create profile in the drop-down list (Publish is the default value).

在“發(fā)布” 對(duì)話框中,單擊“設(shè)置” 鏈接,然后選擇“設(shè)置” 選項(xiàng)卡。In the Publish dialog box, click the Settings link, and then select the Settings tab.

將配置設(shè)置為“調(diào)試” ,選擇“在發(fā)布前刪除所有現(xiàn)有文件” ,然后單擊“保存” 。Set the configuration to Debug, select Delete all existing files prior to publish, and then click Save.

備注

如果使用發(fā)布生成,則在發(fā)布時(shí),需要在 web.config 文件中禁用調(diào)試。If you use a Release build, you disable debugging in the web.config file when you publish.

單擊“發(fā)布” 。Click Publish.

應(yīng)用程序?qū)㈨?xiàng)目的“調(diào)試” 配置發(fā)布到本地文件夾。The application publishes a Debug configuration of the project to the local folder. “輸出”窗口中將顯示進(jìn)度。Progress shows in the Output window.

將 ASP.NET 項(xiàng)目目錄從 Visual Studio 計(jì)算機(jī)復(fù)制到 Windows Server 計(jì)算機(jī)上為 ASP.NET 應(yīng)用配置的本地目錄中(本例中為 C:\Publish )。Copy the ASP.NET project directory from the Visual Studio computer to the local directory configured for the ASP.NET app (in this example, C:\Publish) on the Windows Server computer. 在本教程中,我們假設(shè)你進(jìn)行手動(dòng)復(fù)制,不過(guò),你也可以使用其他工具,例如 PowerShell、Xcopy 或 Robocopy。In this tutorial, we assume you are copying manually, but you can use other tools like PowerShell, Xcopy, or Robocopy.

注意

如果需要更改代碼或重新生成,則必須重新發(fā)布并重復(fù)此步驟。If you need to make changes to the code or rebuild, you must republish and repeat this step. 復(fù)制到遠(yuǎn)程計(jì)算機(jī)的可執(zhí)行文件必須與你的本地源和符號(hào)完全匹配。The executable you copied to the remote machine must exactly match your local source and symbols. 如果沒(méi)有這樣做,則在嘗試調(diào)試進(jìn)程時(shí),你會(huì)在 Visual Studio 中收到 cannot find or open the PDB file 警告。If you do not do this you will receive a cannot find or open the PDB file warning in Visual Studio when you attempt to debug the process.

在 Windows Server 上,通過(guò)在瀏覽器中打開(kāi)應(yīng)用來(lái)驗(yàn)證是否可以正常運(yùn)行應(yīng)用。On the Windows Server, verify that you can run the app correctly by opening the app in your browser.

如果應(yīng)用無(wú)法正常運(yùn)行,則說(shuō)明服務(wù)器和 Visual Studio 計(jì)算機(jī)上安裝的 ASP.NET 版本可能不匹配,或者 IIS 或網(wǎng)站配置可能有問(wèn)題。If the app doesn't run correctly, there may be a mismatch between the version of ASP.NET installed on your server and your Visual Studio machine, or you may have an issue with your IIS or Web site configuration. 請(qǐng)重新檢查前面的步驟。Recheck earlier steps.

在 Windows Server 上下載并安裝遠(yuǎn)程工具Download and Install the remote tools on Windows Server

下載與 Visual Studio 版本匹配的遠(yuǎn)程工具版本。Download the version of the remote tools that matches your version of Visual Studio.

在要調(diào)試的遠(yuǎn)程設(shè)備或服務(wù)器上(而不是 Visual Studio 計(jì)算機(jī)上),請(qǐng)從下表中的鏈接下載并安裝正確的遠(yuǎn)程工具版本。On the remote device or server that you want to debug on, rather than the Visual Studio machine, download and install the correct version of the remote tools from the links in the following table.

下載適合 Visual Studio 版本的最新遠(yuǎn)程工具。Download the most recent remote tools for your version of Visual Studio. 最新的遠(yuǎn)程工具版本與早期的 Visual Studio 版本兼容,但早期的遠(yuǎn)程工具版本與后來(lái)的 Visual Studio 版本不兼容。The latest remote tools version is compatible with earlier Visual Studio versions, but earlier remote tools versions aren't compatible with later Visual Studio versions. (例如,如果使用的是 Visual Studio 2017,請(qǐng)下載 Visual Studio 2017 遠(yuǎn)程工具的最新更新。(For example, if you are using Visual Studio 2017, download the latest update of the remote tools for Visual Studio 2017. 在這種情況下,請(qǐng)不要下載 Visual Studio 2019 的遠(yuǎn)程工具。)In this scenario, do not download the remote tools for Visual Studio 2019.)

下載與要安裝遠(yuǎn)程工具的計(jì)算機(jī)具有相同體系結(jié)構(gòu)的遠(yuǎn)程工具。Download the remote tools with the same architecture as the machine you're installing them on. 例如,如果要在運(yùn)行 64 位操作系統(tǒng)的遠(yuǎn)程計(jì)算機(jī)上調(diào)試 32 位應(yīng)用,請(qǐng)安裝 64 位遠(yuǎn)程工具。For example, if you want to debug a 32-bit app on a remote computer running a 64-bit operating system, install the 64-bit remote tools.

VersionVersion

鏈接Link

說(shuō)明Notes

Visual Studio 2019Visual Studio 2019

兼容所有 Visual Studio 2019 版本。Compatible with all Visual Studio 2019 versions. 下載與設(shè)備操作系統(tǒng)(x86、x64 或 ARM64)匹配的版本。Download the version matching your device operating system (x86, x64, or ARM64). 在 Windows 服務(wù)器上,請(qǐng)參閱取消阻止文件下載,獲取有關(guān)下載遠(yuǎn)程工具的幫助。On Windows Server, see Unblock the file download for help downloading the remote tools.

Visual Studio 2017Visual Studio 2017

兼容所有 Visual Studio 2017 版本。Compatible with all Visual Studio 2017 versions. 下載與設(shè)備操作系統(tǒng)(x86、x64 或 ARM64)匹配的版本。Download the version matching your device operating system (x86, x64, or ARM64). 在 Windows 服務(wù)器上,請(qǐng)參閱取消阻止文件下載,獲取有關(guān)下載遠(yuǎn)程工具的幫助。On Windows Server, see Unblock the file download for help downloading the remote tools.

Visual Studio 2015Visual Studio 2015

Visual Studio 2015 的遠(yuǎn)程工具可從 My.VisualStudio.com 獲取。Remote tools for Visual Studio 2015 are available from My.VisualStudio.com. 如果出現(xiàn)提示,請(qǐng)加入免費(fèi)的 Visual Studio Dev Essentials 計(jì)劃,或使用 Visual Studio 訂閱 ID 登錄。If prompted, join the free Visual Studio Dev Essentials program, or sign in with your Visual Studio subscription ID. 在 Windows 服務(wù)器上,請(qǐng)參閱取消阻止文件下載,獲取有關(guān)下載遠(yuǎn)程工具的幫助。On Windows Server, see Unblock the file download for help downloading the remote tools.

Visual Studio 2013Visual Studio 2013

Visual Studio 2013 文檔中的下載頁(yè)面Download page in Visual Studio 2013 documentation

Visual Studio 2012Visual Studio 2012

Visual Studio 2012 文檔中的下載頁(yè)面Download page in Visual Studio 2012 documentation

VersionVersion

鏈接Link

說(shuō)明Notes

Visual Studio 2017Visual Studio 2017

兼容所有 Visual Studio 2017 版本。Compatible with all Visual Studio 2017 versions. 下載與設(shè)備操作系統(tǒng)(x86、x64 或 ARM64)匹配的版本。Download the version matching your device operating system (x86, x64, or ARM64). 在 Windows 服務(wù)器上,請(qǐng)參閱取消阻止文件下載,獲取有關(guān)下載遠(yuǎn)程工具的幫助。On Windows Server, see Unblock the file download for help downloading the remote tools. For the most recent version of the remote tools, open the Visual Studio 2019 doc.

Visual Studio 2015Visual Studio 2015

Visual Studio 2015 的遠(yuǎn)程工具可從 My.VisualStudio.com 獲取。Remote tools for Visual Studio 2015 are available from My.VisualStudio.com. 如果出現(xiàn)提示,請(qǐng)加入免費(fèi)的 Visual Studio Dev Essentials 計(jì)劃,或使用 Visual Studio 訂閱 ID 登錄。If prompted, join the free Visual Studio Dev Essentials program, or sign in with your Visual Studio subscription ID. 在 Windows 服務(wù)器上,請(qǐng)參閱取消阻止文件下載,獲取有關(guān)下載遠(yuǎn)程工具的幫助。On Windows Server, see Unblock the file download for help downloading the remote tools.

Visual Studio 2013Visual Studio 2013

Visual Studio 2013 文檔中的下載頁(yè)面Download page in Visual Studio 2013 documentation

Visual Studio 2012Visual Studio 2012

Visual Studio 2012 文檔中的下載頁(yè)面Download page in Visual Studio 2012 documentation

可以通過(guò)將 msvsmon.exe 復(fù)制到遠(yuǎn)程計(jì)算機(jī),而不是安裝遠(yuǎn)程工具來(lái)運(yùn)行遠(yuǎn)程調(diào)試器。You can run the remote debugger by copying msvsmon.exe to the remote computer, rather than installing the remote tools. 但是,遠(yuǎn)程調(diào)試器配置向?qū)?(rdbgwiz.exe) 僅在安裝遠(yuǎn)程工具時(shí)才可用。However, the Remote Debugger Configuration Wizard (rdbgwiz.exe) is available only when you install the remote tools. 如果要將遠(yuǎn)程調(diào)試器作為服務(wù)運(yùn)行,則可能需要使用向?qū)нM(jìn)行配置。You may need to use the wizard for configuration if you want to run the remote debugger as a service.

備注

若要在 ARM 設(shè)備上調(diào)試 Windows 10 應(yīng)用,請(qǐng)使用 ARM64,它可用于最新版本的遠(yuǎn)程工具。To debug Windows 10 apps on ARM devices, use ARM64, which is available with the latest version of the remote tools.

若要在 Windows RT 設(shè)備上調(diào)試 Windows 10 應(yīng)用,請(qǐng)使用 ARM,它僅在 Visual Studio 2015 遠(yuǎn)程工具下載中可用。To debug Windows 10 apps on Windows RT devices, use ARM, which is available only in the Visual Studio 2015 remote tools download.

在 Windows Server 上設(shè)置遠(yuǎn)程調(diào)試器Set up the remote debugger on Windows Server

在遠(yuǎn)程計(jì)算機(jī)上,從“開(kāi)始”菜單中查找并啟動(dòng)“遠(yuǎn)程調(diào)試器” 。On the remote computer, find and start the Remote Debugger from the Start menu.

如果你沒(méi)有遠(yuǎn)程計(jì)算機(jī)的管理權(quán)限,請(qǐng)右鍵單擊“遠(yuǎn)程調(diào)試器”應(yīng)用,然后選擇“以管理員身份運(yùn)行” 。If you don't have administrative permissions on the remote computer, right-click the Remote Debugger app and select Run as administrator. 否則,正常啟動(dòng)即可。Otherwise, just start it normally.

如果打算附加到以管理員身份運(yùn)行或在其他用戶帳戶(如 IIS)下運(yùn)行的進(jìn)程,請(qǐng)右鍵單擊“遠(yuǎn)程調(diào)試器”應(yīng)用,然后選擇“以管理員身份運(yùn)行” 。If you are planning to attach to a process which is running as an administrator, or is running under a different user account (such as IIS), right-click the Remote Debugger app and select Run as administrator.

當(dāng)?shù)谝淮?或在配置它之前)啟動(dòng)遠(yuǎn)程調(diào)試器時(shí),將顯示“遠(yuǎn)程調(diào)試配置”對(duì)話框。The first time you start the remote debugger (or before you have configured it), the Remote Debugging Configuration dialog box appears.

如果未安裝 Windows Web 服務(wù) API(僅會(huì)在 Windows Server 2008 R2 上發(fā)生這種情況),請(qǐng)選擇“安裝”按鈕。If the Windows Web Services API is not installed, which happens only on Windows Server 2008 R2, select the Install button.

請(qǐng)至少選擇一種要對(duì)其使用遠(yuǎn)程工具的網(wǎng)絡(luò)類型。Select at least one network type you want to use the remote tools on. 如果這些計(jì)算機(jī)通過(guò)域連接,則必須選擇第一項(xiàng)。If the computers are connected through a domain, you must choose the first item. 如果這些計(jì)算機(jī)通過(guò)工作組或家庭組連接,請(qǐng)根據(jù)需要選擇第二或第三項(xiàng)。If the computers are connected through a workgroup or homegroup, choose the second or third item as appropriate.

選擇“配置遠(yuǎn)程調(diào)試”,配置防火墻并啟動(dòng)遠(yuǎn)程調(diào)試器。Select Configure remote debugging to configure the firewall and start the remote debugger.

配置完成后,將顯示“遠(yuǎn)程調(diào)試器”窗口。When configuration is complete, the Remote Debugger window appears.

遠(yuǎn)程調(diào)試器正在等待連接。The remote debugger is now waiting for a connection. 使用顯示的服務(wù)器名稱和端口號(hào)在 Visual Studio 中設(shè)置遠(yuǎn)程連接配置。Use the server name and port number shown to set the remote connection configuration in Visual Studio.

若要停止遠(yuǎn)程調(diào)試器,請(qǐng)選擇“文件” > “退出” 。To stop the remote debugger, select File > Exit. 你可以從“開(kāi)始”菜單或通過(guò)以下命令行重新啟動(dòng)它:You can restart it from the Start menu, or from the command line:

\msvsmon.exe

備注

如果需要為其他用戶添加權(quán)限,請(qǐng)更改遠(yuǎn)程調(diào)試器的身份驗(yàn)證模式或端口號(hào),請(qǐng)參閱配置遠(yuǎn)程調(diào)試器。If you need to add permissions for additional users, change the authentication mode, or port number for the remote debugger, see Configure the remote debugger.

有關(guān)將遠(yuǎn)程調(diào)試器作為服務(wù)運(yùn)行的信息,請(qǐng)參閱將遠(yuǎn)程調(diào)試器作為服務(wù)運(yùn)行。For information on running the remote debugger as a service, see Run the remote debugger as a service.

從 Visual Studio 計(jì)算機(jī)附加到 ASP.NET 應(yīng)用程序Attach to the ASP.NET application from the Visual Studio computer

在 Visual Studio 計(jì)算機(jī)上,打開(kāi)要調(diào)試的解決方案(如果按照本文中的所有步驟操作,則為 MyASPApp)。On the Visual Studio computer, open the solution that you are trying to debug (MyASPApp if you are following all the steps in this article).

在 Visual Studio 中,單擊“調(diào)試”>“附加到進(jìn)程”(Ctrl + Alt + P)。In Visual Studio, click Debug > Attach to Process (Ctrl + Alt + P).

提示

在 Visual Studio 2017 及更高版本中,可以使用“調(diào)試”>“重新附加到進(jìn)程...”重新附加到以前附加到的同一進(jìn)程(Shift + Alt + P)。In Visual Studio 2017 and later versions, you can reattach to the same process you previously attached to by using Debug > Reattach to Process... (Shift + Alt + P).

將限定符字段設(shè)置為 ,并按 Enter 。Set the Qualifier field to and press Enter.

確保 Visual Studio 將所需的端口添加到計(jì)算機(jī)名稱中,其格式為::portVerify that Visual Studio adds the required port to the computer name, which appears in the format: :port

在 Visual Studio 2019 中應(yīng)看到 :4024On Visual Studio 2019, you should see :4024

在 Visual Studio 2017 中應(yīng)看到 :4022On Visual Studio 2017, you should see :4022

端口是必需的。The port is required. 如果看不到端口號(hào),請(qǐng)手動(dòng)添加。If you don't see the port number, add it manually.

單擊“刷新”。Click Refresh.

“可用進(jìn)程” 窗口中將顯示某些進(jìn)程。You should see some processes appear in the Available Processes window.

如果看不到任何進(jìn)程,請(qǐng)嘗試使用 IP 地址而不是遠(yuǎn)程計(jì)算機(jī)名稱(端口是必需的)。If you don't see any processes, try using the IP address instead of the remote computer name (the port is required). 可以在命令行中使用 ipconfig 來(lái)獲取 IPv4 地址。You can use ipconfig in a command line to get the IPv4 address.

如果要使用“查找”按鈕,則可能需要在服務(wù)器上打開(kāi) UDP 端口 3702。If you want to use the Find button, you may need to open UDP port 3702 on the server.

勾選“顯示所有用戶的進(jìn)程” 。Check Show processes from all users.

鍵入進(jìn)程名稱的第一個(gè)字母,以快速查找應(yīng)用。Type the first letter of your process name to quickly find your app.

如果正在 IIS 上使用進(jìn)程內(nèi)托管模型,請(qǐng)選擇正確的 w3wp.exe 進(jìn)程。If you're using the in-process hosting model on IIS, select the correct w3wp.exe process. 從 .NET Core 3 開(kāi)始,這是默認(rèn)設(shè)置。Starting in .NET Core 3, this is the default.

否則,請(qǐng)選擇 dotnet.exe 進(jìn)程。Otherwise, select the dotnet.exe process. (這是進(jìn)程外托管模型。)(This is the out-of-process hosting model.)

如果有多個(gè)進(jìn)程顯示 w3wp.exe 或 dotnet.exe,請(qǐng)檢查“用戶名”列。If you have multiple processes showing w3wp.exe or dotnet.exe, check the User Name column. 在某些情況下,“用戶名”列顯示應(yīng)用池名稱,例如 IIS APPPOOL\DefaultAppPool。In some scenarios, the User Name column shows your app pool name, such as IIS APPPOOL\DefaultAppPool. 如果你看到了應(yīng)用池,但它不是唯一的,則為要調(diào)試的應(yīng)用實(shí)例創(chuàng)建一個(gè)使用新名稱的應(yīng)用池,然后就可以在“用戶名”列中輕松找到它了。If you see the App Pool, but it's not unique, create a new named App Pool for the app instance you want to debug, and then you can find it easily in the User Name column.

單擊 “附加” 。Click Attach.

打開(kāi)遠(yuǎn)程計(jì)算機(jī)的網(wǎng)站。Open the remote computer's website. 在瀏覽器中,轉(zhuǎn)到 http://。In a browser, go to http://.

將顯示 ASP.NET 網(wǎng)頁(yè)。You should see the ASP.NET web page.

在正在運(yùn)行的 ASP.NET 應(yīng)用程序中,單擊指向“關(guān)于”頁(yè)面的鏈接。In the running ASP.NET application, click the link to the About page.

應(yīng)在 Visual Studio 中命中斷點(diǎn)。The breakpoint should be hit in Visual Studio.

排除故障:在 Windows Server 上打開(kāi)必需端口Troubleshooting: Open required ports on Windows Server

在大多數(shù)設(shè)置中,必需端口通過(guò)安裝 ASP.NET 和遠(yuǎn)程調(diào)試器來(lái)打開(kāi)。In most setups, required ports are opened by the installation of ASP.NET and the remote debugger. 但是,你可能需要驗(yàn)證端口是否已打開(kāi)。However, you may need to verify that ports are open.

備注

在 Azure VM 上,必須通過(guò)網(wǎng)絡(luò)安全組打開(kāi)端口。On an Azure VM, you must open ports through the Network security group.

必需端口:Required ports:

80 - 對(duì)于 IIS 是必需的80 - Required for IIS

4024 - 從 Visual Studio 2019 進(jìn)行遠(yuǎn)程調(diào)試時(shí)必需(有關(guān)詳細(xì)信息,請(qǐng)參閱遠(yuǎn)程調(diào)試器端口分配)。4024 - Required for remote debugging from Visual Studio 2019 (see Remote Debugger Port Assignments for more information).

4022 - 從 Visual Studio 2017 進(jìn)行遠(yuǎn)程調(diào)試時(shí)必需(有關(guān)詳細(xì)信息,請(qǐng)參閱遠(yuǎn)程調(diào)試器端口分配)。4022 - Required for remote debugging from Visual Studio 2017 (see Remote Debugger Port Assignments for more information).

UDP 3702 -(可選)發(fā)現(xiàn)端口允許你在附加到 Visual Studio 中的遠(yuǎn)程調(diào)試器時(shí)使用“查找”按鈕。UDP 3702 - (Optional) Discovery port enables you to the Find button when attaching to the remote debugger in Visual Studio.

若要在 Windows Server 上打開(kāi)端口,請(qǐng)打開(kāi)“開(kāi)始”菜單,搜索“高級(jí)安全 Windows 防火墻”。To open a port on Windows Server, open the Start menu, search for Windows Firewall with Advanced Security.

然后選擇“入站規(guī)則”>“新建規(guī)則”>“端口”,單擊“下一步”。Then choose Inbound Rules > New Rule > Port, and then click Next. (對(duì)于 UDP 3702,請(qǐng)改為選擇“出站規(guī)則”。)(For UDP 3702, choose Outbound Rules instead.)

在“特定本地端口”下,輸入端口號(hào),然后單擊“下一步”。Under Specific local ports, enter the port number, click Next.

單擊“允許連接”,單擊“下一步”。Click Allow the Connection, click Next.

選擇要為端口啟用的一個(gè)或多個(gè)網(wǎng)絡(luò)類型,然后單擊“下一步”。Select one or more network types to enable for the port and click Next.

你選擇的類型必須包括遠(yuǎn)程計(jì)算機(jī)連接到的網(wǎng)絡(luò)。The type you select must include the network to which the remote computer is connected.

為入站規(guī)則添加名稱(例如,IIS、Web 部署或 msvsmon),然后單擊“完成”。Add the name (for example, IIS, Web Deploy, or msvsmon) for the Inbound Rule and click Finish.

應(yīng)該能在“入站規(guī)則”或“出站規(guī)則”列表中看到自己的新規(guī)則。You should see your new rule in the Inbound Rules or Outbound Rules list.

如果需要有關(guān)配置 Windows 防火墻的詳細(xì)信息,請(qǐng)參閱配置 Windows 防火墻以便進(jìn)行遠(yuǎn)程調(diào)試。If you want more details on configuring Windows Firewall, see Configure the Windows Firewall for Remote Debugging.

為其他必需端口創(chuàng)建附加規(guī)則。Create additional rules for the other required ports.

總結(jié)

以上是生活随笔為你收集整理的core部署iis的 调试net_远程调试远程 IIS 计算机上的 ASP.NET Core - Visual Studio | Microsoft Docs...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。