Visual Studio debugging Series 12 remote debugging on the remote computer to deploy IIS ASP.NET application

To debug been deployed to IIS ASP.NET application, install and run the tool on a remote computer to deploy the application, and then attach to the application from Visual Studio running.

 

Here's how to set up and configure Visual Studio ASP.NET MVC 4.5.2 application, deploy it to IIS, and how to attach the remote debugger from Visual Studio.

01 Prerequisites

According to the step illustrated herein need Visual Studio 2019.

The server configuration tested these procedures:

  • Windows Server 2012 R2 and IIS 8 (for Windows Server 2008 R2, the server, the steps will be different)
02 Network Requirements
From Windows Server 2008 Service Pack 2 for Windows Server supports remote debugger. For a complete list of requirements, see the requirements .

It does not support the connection between two computers through a proxy debugging. Debugging over high latency or low bandwidth connections, such as dial-up Internet, through the Internet or across countries / regions is not recommended and may fail or is unacceptably slow.

03 application is already running in IIS?
This article includes a basic configuration of IIS on Windows Server as well as steps to deploy applications from Visual Studio. These include steps to ensure that the components required for the application server is installed to run properly, and you are ready for remote debugging.
  • If you run your application in IIS, and only want to download the remote debugger and start debugging, go to download and install the Remote Server tools on Windows .

  • If you need help ensure that your application setup is complete, deploy, and run correctly in IIS, so that you can debug, please follow all the steps in this topic.

04 Creating ASP.NET 4.5.2 application on a computer where Visual Studio
  1. Create a new MVC ASP.NET applications.

    In Visual Studio 2019, type Ctrl + Q to open the search box, type asp.net, select the template, and then select Create a new ASP.NET Web Application (.NET Framework). In the dialog box that appears, name the project MyASPApp, and then select Create. Select the MVC, and choose Create.

  2. Open HomeController.cs file, and  About() set a breakpoint method.

Install and configure IIS on Windows Server

The following steps demonstrate the basic configuration of IIS. For more information or to install the Windows desktop computer, see published to IIS or IIS 8.0 to use ASP.NET 3.5 and 4.5 ASP.NET .

For Windows Server operating system, use the Add Roles and Features Wizard by management dashboard link or links in the Server Manager.  In the "server role" steps, select the "Web Server (IIS)" box.

Select the "Web Server IIS" role in the choice of server roles step.

In the "Role Services" step, select the required IIS role services, or accept the default role services provided. If you want to enable the deployment and use of Web publishing settings deployment, make sure IIS Management Scripts and Tools is selected.

Continue to complete the confirmation steps to install the web server roles and services. After installing Web Server (IIS) role without restarting the server / IIS.

05 updated browser on Windows Server Security Settings

如果在 Internet Explorer (默认情况下已启用) 中启用了增强的安全配置,您可能需要将某些域添加为受信任的站点,以便可以下载某些 web 服务器组件。 添加可信的站点,通过转到Internet 选项 > 安全性 > 受信任的站点 > 站点。 添加以下域。

  • microsoft.com
  • go.microsoft.com
  • download.microsoft.com
  • iis.net

下载软件时,可能会显示请求授予权限以加载各种 web 站点脚本和资源。 以下一些资源不是必需的但若要简化此过程中,单击添加出现提示时。

06 在Windows Server上安装ASP.NET 4.5

如果你想要在 IIS 上安装 ASP.NET 的更多详细的信息,请参阅IIS 8.0 使用 ASP.NET 3.5 和 ASP.NET 4.5

  1. 在服务器管理器的左窗格中,选择IIS。 右键单击服务器并选择“Internet Information Services (IIS)管理器” 。

  2. 使用 Web 平台安装程序 (WebPI) 安装 ASP.NET 4.5 (从 Windows Server 2012 R2 中的服务器节点,选择获取新的 Web 平台组件,然后搜索 ASP.NET)

    RemoteDBG_IIS_AspNet_45

    如果使用 Windows Server 2008 R2,安装 ASP.NET 4 改为使用此命令:

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

  3. 重启系统(或在命令提示符处依次执行“net stop was /y”和“net start w3svc”,了解系统路径的更改) 。

07 选择部署选项

如果您需要帮助将应用部署到 IIS,请考虑这些选项:

  • 通过在 IIS 中创建的发布设置文件和导入 Visual Studio 中的设置部署。 在某些情况下,这是一种将应用部署的快速方法。 创建发布设置文件时,权限自动将会在 IIS 中设置。

  • 部署发布到本地文件夹并将输出的首选方法复制到 IIS 上的已准备好应用程序文件夹。

08 (可选)使用发布设置文件进行部署
09 (可选)部署发布到本地文件夹
10 下载并安装 Windows Server 上的远程工具
11 设置 Windows Server 上的远程调试器
12 从 Visual Studio 计算机附加到 ASP.NET 应用程序
  1. Visual Studio 计算机上,打开要调试的解决方案 (MyASPApp在您按照这篇文章中的步骤)。

  2. 在 Visual Studio 中,单击调试 > 附加到进程(Ctrl + Alt + P)。

    在 Visual Studio 2017 和更高版本中,您可以重新附加到您以前使用附加到的同一个进程调试 > 重新附加到进程... (Shift + Alt + P)。

  3. 将限定符字段设置为 <远程计算机名称> 然后按Enter。

    验证 Visual Studio 将所需的端口添加到计算机名称,将出现在格式: <远程计算机名称>:端口

    在 Visual Studio 2019,你会看到 <远程计算机名称>:4024

    端口是必需的。 如果看不到的端口号,请手动添加它。

  4. 单击“刷新” 。 “可用进程” 窗口中将显示某些进程。

    如果看不到任何进程,请尝试使用的 IP 地址而不远程计算机名称 (端口是必需的)。可以使用ipconfig获取 IPv4 地址的命令行中。

  5. 勾选“显示所有用户的进程” 。

  6. 键入进程名称,可以快速找到的第一个字母w3wp.exe为 ASP.NET 4.5。

    如果有多个进程显示w3wp.exe,检查用户名列。 在某些情况下,用户名列显示你的应用程序池名称,如IIS APPPOOL\DefaultAppPool。 如果你看到应用程序池标识正确的进程的简单办法是创建一个新应用池命名为你想要调试的应用程序实例,然后您可以找到它轻松地在用户名列。

    RemoteDBG_AttachToProcess

  7. 单击“附加”

  8. 打开远程计算机的网站。 在浏览器中,转到 http://<remote computer name> 。

    将显示 ASP.NET 网页。

  9. 在运行的 ASP.NET 应用程序,单击链接到有关页。

    应在 Visual Studio 中命中断点。

13 故障排除:Windows Server 上打开所需的端口
 在大多数设置中,通过安装ASP.NET和远程调试器来打开所需的端口。但是,您可能需要验证端口是否已打开。

在Azure VM上,您必须通过网络安全组打开端口。

所需端口:

  • 80 - IIS必需
  • UDP 3702 - (可选)在Visual Studio中附加到远程调试器时,发现端口使您可以使用“ 查找”按钮。
  1. 若要打开 Windows 服务器上的端口,请打开启动菜单中,搜索高级安全 Windows 防火墙。

  2. Then select an inbound rule> New Rules> port. And select Next specific local port, the input port number, click Next, and then allowed to connect, click Next, and add the name (IIS, Web Deploy, or msvsmon) inbound rules.

    If you would like more information about Windows Firewall configuration, see Configuring Windows Firewall for remote debugging .

  3. Create additional ports required other rules.

 

 

Guess you like

Origin www.cnblogs.com/SavionZhang/p/11276816.html