Skip to content

Commit

Permalink
Merge pull request #10214 from MicrosoftDocs/main638495105574686332sy…
Browse files Browse the repository at this point in the history
…nc_temp

For protected branch, push strategy should use PR and merge to target branch method to work around git push error
  • Loading branch information
learn-build-service-prod[bot] authored Apr 23, 2024
2 parents fc9824b + 8e29a1f commit c9884a7
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 92 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Remote debug ASP.NET on an IIS computer"
description: Learn how to set up and configure a Visual Studio ASP.NET MVC 4.8 application, deploy it to IIS, and attach the remote debugger from Visual Studio.
ms.date: 11/21/2023
ms.date: 04/23/2024
ms.topic: "conceptual"
author: "mikejo5000"
ms.author: "mikejo"
Expand Down Expand Up @@ -117,7 +117,7 @@ You can use this option to create a publish settings file and import it into Vis

[!INCLUDE [install-web-deploy-with-hosting-server](../deployment/includes/import-publish-settings-vs.md)]

After the app deploys successfully, it should start automatically. If the app doesn't start from Visual Studio, start the app in IIS to verify that it runs correctly.
After the app deploys successfully, it should start automatically. If the app doesn't start after deployment, start the app in IIS to verify that it runs correctly.

When you're ready, switch to a debug configuration.

Expand Down Expand Up @@ -199,57 +199,86 @@ For information on running the remote debugger as a service, see [Run the remote

## <a name="BKMK_attach"></a> Attach to the ASP.NET application from the Visual Studio computer

1. On the Visual Studio computer, open the solution that you're trying to debug (**MyASPApp** if you're following the steps in this article).
::: moniker range=">=vs-2022"

Starting in Visual Studio 2022 version 17.10 Preview 2, the Attach to Process dialog box has changed. If you need instructions that match the older dialog box, switch to the Visual Studio 2019 view (upper left version selector in the article).

1. On the Visual Studio computer, open the solution that you're trying to debug (**MyASPApp** if you're following all the steps in this article).

2. In Visual Studio, select **Debug > Attach to Process** (Ctrl + Alt + P).

> [!TIP]
> 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).
> [!TIP]
> 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).

3. Set the Qualifier field to **\<remote computer name>** and press **Enter**.
3. Set the **Connection Type** to **Remote (Windows)**.

The **Connection Target** option appears.

Verify that Visual Studio adds the required port to the computer name, which appears in the format: **\<remote computer name>:port**
Set the **Connection Target** to **\<remote computer name>** and press **Enter**.

::: moniker range=">=vs-2022"
On Visual Studio 2022, you should see **\<remote computer name>:4026**
::: moniker-end
::: moniker range="vs-2019"
On Visual Studio 2019, you should see **\<remote computer name>:4024**
::: moniker-end
Verify that Visual Studio adds the required port to the computer name, which appears in the format: **\<remote computer name>:port**

The port is required. If you don't see the port number, add it manually.
On Visual Studio 2022, you should see **\<remote computer name>:4026**

The port is required. If you don't see the port number, add it manually.
::: moniker-end

::: moniker range="vs-2019"
1. On the Visual Studio computer, open the solution that you're trying to debug (**MyASPApp** if you're following all the steps in this article).

2. In Visual Studio, select **Debug > Attach to Process** (Ctrl + Alt + P).

> [!TIP]
> 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).

3. Set the Qualifier field to **\<remote computer name>** and press **Enter**.

Verify that Visual Studio adds the required port to the computer name, which appears in the format: **\<remote computer name>:port**

On Visual Studio 2019, you should see **\<remote computer name>:4024**

The port is required. If you don't see the port number, add it manually.
::: moniker-end
4. Select **Refresh**.
You should see some processes appear in the **Available Processes** window.

If you don't see any processes, try using the IP address instead of the remote computer name (the port is required). You can use `ipconfig` in a command line to get the IPv4 address.
You should see some processes appear in the **Available Processes** window.

If you don't see any processes, try using the IP address instead of the remote computer name (the port is required). You can use `ipconfig` in a command line to get the IPv4 address.

If you want to use the **Find** button, you might need to [open outbound UDP port 3702](#bkmk_openports) on the server.

5. Check **Show processes from all users**.

6. Type the first letter of a process name to quickly find **w3wp.exe** for ASP.NET 4.5.
6. Type the first letter of a process name to quickly find *w3wp.exe* for ASP.NET 4.5.

If you have multiple processes showing **w3wp.exe**, check the **User Name** column. In some scenarios, the **User Name** column shows your app pool name, such as **IIS APPPOOL\DefaultAppPool**. If you see the App Pool, an easy way to identify the correct process is to 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.
If you have multiple processes showing w3wp.exe, check the User Name column. In some scenarios, the User Name column shows your app pool name, such as IIS APPPOOL\DefaultAppPool. If you see the App Pool, an easy way to identify the correct process is to 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.

![RemoteDBG_AttachToProcess](../debugger/media/vs-2019/remotedbg-attachtoprocess.png "RemoteDBG_AttachToProcess")
::: moniker range=">=vs-2022"
![Screenshot of Attach to Process dialog.](../debugger/media/vs-2022/remote-debug-attach-to-process-aspnet-core.png "RemoteDBG_AttachToProcess")
::: moniker-end
::: moniker range="vs-2019"
![Screenshot of Attach to Process dialog.](../debugger/media/vs-2019/remotedbg-attachtoprocess-aspnetcore.png "RemoteDBG_AttachToProcess")
::: moniker-end

7. Select **Attach**
7. Select **Attach**.

8. Open the remote computer's website. In a browser, go to **http://\<remote computer name>**.

You should see the ASP.NET web page.
You should see the ASP.NET web page.

9. In the running ASP.NET application, select the link to the **Privacy** page.

The breakpoint should be hit in Visual Studio.
The breakpoint should be hit in Visual Studio.

If you're unable to attach or hit the breakpoint, see [Troubleshoot remote debugging](../debugger/troubleshooting-remote-debugging.md).
If you're unable to attach or hit the breakpoint, see [Troubleshoot remote debugging](../debugger/troubleshooting-remote-debugging.md).

## Troubleshooting IIS deployment

- If you can't connect to the host using the host name, try the IP address instead.
- Make sure the required ports are open on the remote server.
- Verify that the version of ASP.NET used in your app is the same as the version you installed on the server. For your app, you can view and set the version in the **Properties** page. To set the app to a different version, that version must be installed.
- If the app tried to open, but you see a certificate warning, choose to trust the site. If you already closed the warning, you can edit the publishing profile, a *.pubxml file, in your project and add the following element (for test only): `<AllowUntrustedCertificate>true</AllowUntrustedCertificate>`
- If the app doesn't start from Visual Studio, start the app in IIS to test that it deployed correctly.
- After it's deployed, start the app in IIS to test that it deployed correctly.
- Check the Output window in Visual Studio for status information, and check your error messages.

## <a name="bkmk_openports"></a> Open required ports on Windows Server
Expand Down Expand Up @@ -277,7 +306,9 @@ In addition, these ports should already be opened by the ASP.NET installation:

### Open a port

1. To open a port on Windows Server, open the **Start** menu, search for **Windows Firewall with Advanced Security**.
1. To open a port on Windows Server, open the **Start** menu, search for **Windows Defender Firewall** or **Windows Firewall with Advanced Security**.

For **Windows Defender Firewall**, choose **Advanced settings**.

1. Then choose **Inbound Rules > New Rule > Port**. Choose **Next** and under **Specific local ports**, enter the port number, select **Next**, then **Allow the Connection**, select Next, and add the name (**IIS**, **Web Deploy**, or **msvsmon**) for the Inbound Rule.

Expand Down
71 changes: 50 additions & 21 deletions docs/debugger/remote-debugging-aspnet-on-a-remote-iis-computer.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Remote debug ASP.NET Core on a remote IIS computer
description: Debug an ASP.NET Core application that has been deployed to a remote Internet Information Services (IIS) computer using the Visual Studio remote debugger.
ms.date: 11/21/2023
ms.date: 04/23/2024
ms.topic: "conceptual"
author: "mikejo5000"
ms.author: "mikejo"
Expand Down Expand Up @@ -44,7 +44,7 @@ This article includes steps on setting up a basic configuration of IIS on Window

In Visual Studio, choose **File** > **Start window** to open the Start window, and then choose **Create a new project**. In the search box, type **web app**, then choose **C#** as the language, then choose **ASP.NET Core Web Application (Model-View-Controller)**, and then choose **Next**. On the next screen, name the project **MyASPApp**, and then choose **Next**.

Choose either the recommended target framework or .NET 8, and then choose **Create**.
Choose either the recommended target framework or .NET 8, and then choose **Create**. The version must match the version installed on the server.

1. Open the *HomeController.cs* file in the Controllers folder and set a breakpoint in the `return View;` statement in the `Privacy` method.

Expand All @@ -71,6 +71,9 @@ When you download the software, you might get requests to grant permission to lo

For the current .NET Core hosting bundle, install the [ASP.NET Core Hosting Bundle](https://dotnet.microsoft.com/permalink/dotnetcore-current-windows-runtime-bundle-installer).

> [!NOTE]
> If you previously installed IIS, the ASP.NET Core IIS Module gets installed with ASP.NET Core. Otherwise, install the ASP.NET Core IIS Module manually.
For .NET Core 2, install the [.NET Core Windows Server Hosting](https://aka.ms/dotnetcore-2-windowshosting).

> [!NOTE]
Expand Down Expand Up @@ -113,7 +116,7 @@ You can use this option create a publish settings file and import it into Visual

After the app deploys successfully, it should start automatically.

- If the app doesn't start from Visual Studio, start the app in IIS to verify that it runs correctly.
- If the app doesn't start after deployment, start the app in IIS to verify that it runs correctly.
- For ASP.NET Core, make sure the Application pool field for the **DefaultAppPool** is set to **No Managed Code**.

When you're ready, switch to a debug configuration.
Expand Down Expand Up @@ -178,56 +181,80 @@ Download the version of the remote tools that matches your version of Visual Stu
For information on running the remote debugger as a service, see [Run the remote debugger as a service](../debugger/remote-debugging.md#bkmk_configureService).

## <a name="BKMK_attach"></a> Attach to the ASP.NET application from the Visual Studio computer
## <a name="BKMK_attach"></a> Attach to the ASP.NET Core application from the Visual Studio computer

::: moniker range=">=vs-2022"

Starting in Visual Studio 2022 version 17.10 Preview 2, the Attach to Process dialog box has changed. If you need instructions that match the older dialog box, switch to the Visual Studio 2019 view (upper left version selector in the article).

1. On the Visual Studio computer, open the solution that you're trying to debug (**MyASPApp** if you're following all the steps in this article).

1. In Visual Studio, select **Debug > Attach to Process** (Ctrl + Alt + P).
2. In Visual Studio, select **Debug > Attach to Process** (Ctrl + Alt + P).

> [!TIP]
> 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).
1. Set the Qualifier field to **\<remote computer name>** and press **Enter**.
3. Set the **Connection Type** to **Remote (Windows)**.

The **Connection Target** option appears.

Set the **Connection Target** to **\<remote computer name>** and press **Enter**.

Verify that Visual Studio adds the required port to the computer name, which appears in the format: **\<remote computer name>:port**

::: moniker range=">=vs-2022"
On Visual Studio 2022, you should see **\<remote computer name>:4026**
::: moniker-end

::: moniker range="vs-2019"
The port is required. If you don't see the port number, add it manually.
::: moniker-end

::: moniker range="vs-2019"
1. On the Visual Studio computer, open the solution that you're trying to debug (**MyASPApp** if you're following all the steps in this article).

2. In Visual Studio, select **Debug > Attach to Process** (Ctrl + Alt + P).

> [!TIP]
> 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).
3. Set the Qualifier field to **\<remote computer name>** and press **Enter**.

Verify that Visual Studio adds the required port to the computer name, which appears in the format: **\<remote computer name>:port**

On Visual Studio 2019, you should see **\<remote computer name>:4024**
::: moniker-end

The port is required. If you don't see the port number, add it manually.

1. Select **Refresh**.
::: moniker-end
4. Select **Refresh**.

You should see some processes appear in the **Available Processes** window.

If you don't see any processes, try using the IP address instead of the remote computer name (the port is required). You can use `ipconfig` in a command line to get the IPv4 address.

If you want to use the **Find** button, you might need to [open UDP port 3702](#bkmk_openports) on the server.
If you want to use the **Find** button, you might need to [open outbound UDP port 3702](#bkmk_openports) on the server.

1. Check **Show processes from all users**.
5. Check **Show processes from all users**.

1. Type the first letter of your process name to quickly find your app.
6. Type the first letter of your process name to quickly find your app.

* If you're using the [in-process hosting model](/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-3.1&preserve-view=true#hosting-models) on IIS, select the correct **w3wp.exe** process. Starting in .NET Core 3, this process is the default.

* Otherwise, select the **dotnet.exe** process. (This is the out-of-process hosting model.)

If you have multiple processes showing *w3wp.exe* or *dotnet.exe*, check the **User Name** column. In some scenarios, the **User Name** column shows your app pool name, such as **IIS APPPOOL\DefaultAppPool**. 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.

![RemoteDBG_AttachToProcess](../debugger/media/vs-2019/remotedbg-attachtoprocess-aspnetcore.png "RemoteDBG_AttachToProcess")
::: moniker range=">=vs-2022"
![Screenshot of Attach to Process dialog.](../debugger/media/vs-2022/remote-debug-attach-to-process-aspnet-core.png "RemoteDBG_AttachToProcess")
::: moniker-end
::: moniker range="vs-2019"
![Screenshot of Attach to Process dialog.](../debugger/media/vs-2019/remotedbg-attachtoprocess-aspnetcore.png "RemoteDBG_AttachToProcess")
::: moniker-end

1. Select **Attach**.
7. Select **Attach**.

1. Open the remote computer's website. In a browser, go to **http://\<remote computer name>**.
8. Open the remote computer's website. In a browser, go to **http://\<remote computer name>**.

You should see the ASP.NET web page.

1. In the running ASP.NET application, select the link to the **Privacy** page.
9. In the running ASP.NET application, select the link to the **Privacy** page.

The breakpoint should be hit in Visual Studio.

Expand All @@ -240,7 +267,7 @@ For information on running the remote debugger as a service, see [Run the remote
- For ASP.NET Core, you need to make sure that the Application pool field for the **DefaultAppPool** is set to **No Managed Code**.
- Verify that the version of ASP.NET used in your app is the same as the version you installed on the server. For your app, you can view and set the version in the **Properties** page. To set the app to a different version, that version must be installed.
- If the app tried to open, but you see a certificate warning, choose to trust the site. If you already closed the warning, you can edit the publishing profile, a *.pubxml file, in your project and add the following element (for test only): `<AllowUntrustedCertificate>true</AllowUntrustedCertificate>`
- If the app doesn't start from Visual Studio, start the app in IIS to test that it deployed correctly.
- After it's deployed, start the app in IIS to test that it deployed correctly.
- Check the Output window in Visual Studio for status information, and check your error messages.

## <a name="bkmk_openports"></a> Open required ports on Windows Server
Expand Down Expand Up @@ -270,7 +297,9 @@ In addition, these ports should already be opened by the ASP.NET installation:

### Open a port

1. To open a port on Windows Server, open the **Start** menu, search for **Windows Firewall with Advanced Security**.
1. To open a port on Windows Server, open the **Start** menu, search for **Windows Defender Firewall** or **Windows Firewall with Advanced Security**.

For **Windows Defender Firewall**, choose **Advanced settings**.

1. Then choose **Inbound Rules > New Rule > Port**, and then select **Next**. (For UDP 3702, choose **Outbound Rules** instead.)

Expand Down
Loading

0 comments on commit c9884a7

Please sign in to comment.