Introducing the private preview of port tunneling in Visual Studio for ASP.NET Core projects

Sayed Ibrahim Hashimi

In Visual Studio 2022 17.3 Preview 1.1 we added support to port tunneling (forwarding) to your ASP.NET Core web projects. Port tunneling enables connections between machines that cannot directly connect to each other. Port tunneling is also referred to as port forwarding, or web tunneling. Some cases where you may want to use port tunneling while developing an ASP.NET Core app include:

These are just a few examples of when you may want to use port tunneling with your web projects. This feature depends on a private preview which you must sign up for.

To get started follow these steps.

  1. Sign up for the private preview of port tunneling in Visual Studio.
  2. Download the 17.3 Preview 1.1 Visual Studio update.
  3. Enable the preview feature in Visual Studio.
  4. Configure your project.

1: Sign up for the private preview of port tunneling in Visual Studio

To get started with the, sign up for the private preview at the link below. You should sign in with the same account that you are using in Visual Studio. Port tunneling will not work without signing up for this preview.

After signing up, download the Visual Studio preview and enable the feature in Visual Studio.

2: Download the 17.3 Preview 1.1 Visual Studio update

We added support for this preview feature in Visual Studio 2022 17.3 Preview 1.1. You can download that at the link below.

3: Enable the preview in Visual Studio

In Visual Studio go to Tool > Options > Preview Features and check the Enable port tunneling for Web Applications option.

vs preview features port forwarding

4: Configure your project

When developing ASP.NET Core projects in Visual Studio, the settings to launch your application are stored in the file at Properties/launchSettings.json. This file contains one, or more, launch profiles for your web app. In order to enable the tunnel to be created, or connected, when you run your app, add the property “createTunnel”: true in the launch profile. For example, below is a full launchSettings.json file for an ASP.NET Core web project.

  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:28981",
      "sslPort": 44342
  "profiles": {
    "MyWebApp": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:7130;http://localhost:5130",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      "createTunnel": true
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"

The property that needs to be added is in bold above. When you run, or debug, your application in Visual Studio. Instead of launching the localhost URL, the tunnel URL will be launched, which will then connect to the localhost endpoint. Take a look at the animation below.

Note: when this feature was originally implemented the access was set to public by default. In more recent updates, we default to private access, where only the signed in user has access to that tunnel. You can control the access with the property “tunnelAuthentication”, which can be set to “private”, “org” or “public”. For org access, the user accessing that tunnel must have access to the organization in which the tunnel was created.

run in vs with tunnel

When the web app is launched, you can see that the browser is not navigating to the localhost URL, but instead using the public tunnel URL. This URL can be accessed outside of your local environment. You could share the public URL with a friend or colleague to test out the application. If you wanted to test your web app on an external device like a phone or tablet, you can navigate to the URL on the device. To simplify this, you can generate a QR code to the URL in the Edge browser. To create the QR code in Edge, click on the URL bar and the QR code button should appear. Click on that to generate, and view, the QR code.


qr code

You can scan this QR code with your phone, or tablet, to navigate to the URL.

What to do if you run into issues?

This is an early preview, so you may run into some issues when using this feature. The best method to report issues is using the built in Report a Problem support in Visual Studio. You can also leave a comment here or reach out to Sayed on Twitter at @SayedIHashimi.

Known Issues

  • accounts are not currently supported.
    • We will add support for accounts in a future update.
  • Multiple accounts in Visual Studio
    • If you are signed in with multiple Azure accounts in Visual Studio, the tunnel will be created with the first Azure account detected.
    • Later we will add the ability to select a specific account to create the tunnel with.
    • If you see a dialog with the following message, the account that is signed into Visual Studio doesn’t have access to create the tunnel. Ensure that you are signed in with an Azure account in Visual Studio.
      • user acct error
  • Tunnel authentication
    • Currently all tunnels are created with anonymous authentication enabled.
    • We are planning to make all new tunnels secure by default in a future update, with the ability to configure the auth settings.
  • 302 Error
    • When accessing the tunnel URL the request may be redirected, if the client is not following redirects you may encounter a 302 error.
    • When you get a 302 error you can modify the global URL to point to the specific data center where the tunnel exists. For example if your global URL is, instead use
    • We have seen 302 errors when configuring GitHub web hooks. We are going to work with GitHub to resolve this issue.

Wrap Up

In this post we introduced the new web tunneling feature for ASP.NET Core apps in Visual Studio, and what steps you should take to try it out. This is just an early preview; we will continue to improve this experience so that we can release this in a non-preview build. Please try it out and let us know how it’s working for you.