Sharing Web Apps Using Dev Tunnels In Visual Studio 2022

Sometimes we want to share what we are doing, the changes that we are performing, or a proof of concept with others. To do this, we need to publish our app or share the screen with others and show step-by-step what we are doing and how it works. Ngrok is an application for this scenario; it's petty simple to use and free with some limitations.

In Visual Studio 2022, we have now the possibility to share quickly our web application with a https public URL.

Since this is a preview feature in Visual Studio we need to navigate to Tools -> Manage preview features

Sharing Web Apps Using Dev Tunnels In Visual Studio 2022

And check the option "Enable dev tunnels for web applications"

Sharing Web Apps Using Dev Tunnels In Visual Studio 2022

After that in our ASP.NET core web application, we need to open launchsettings.json and add 2 properties to the general profile to include now the functionality to open the application using dev tunnels, or you can also create a new profile.

Example

"profiles": {
    "WebApplication1": {
        "commandName": "Project",
        "dotnetRunMessages": true,
        "launchBrowser": true,
        "applicationUrl": "https://localhost:7211;http://localhost:5258",
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "devTunnelEnabled": true,
        "devTunnelAccess": true
    },
    "IIS Express": {
        "commandName": "IISExpress",
        "launchBrowser": true,
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        }
    }
}

Finally, you can now run the profile changed or the new profile that includes the 2 dev tunnel properties and run the application in a public URL that other people can see.

Sharing Web Apps Using Dev Tunnels In Visual Studio 2022

We need to confirm that we want to use the dev tunnel in the browser

Sharing Web Apps Using Dev Tunnels In Visual Studio 2022

This is the website running using dev tunnels:

Sharing Web Apps Using Dev Tunnels In Visual Studio 2022

You can now share this site with others, every time that you can execute your project Visual Studio will generate a new URL.


Similar Articles