James Flower

C# .NET and Web Developer

Setup Gitpod for a .NET 6+ Web App

Posted on
2 min read

Gitpod is a service which provides development environments in the cloud, but a .NET web app will need some extra configuration to make it accessible when running from a development workspace.

You can use Gitpod by logging in with an account from a source control provider (such as GitHub or GitLab), and then selecting the repository you would like to use from the list of available repositories.

After you have selected a repository, a new workspace is created and the files will be cloned into the workspace ready for you to work on. The VS Code Browser editor will then open in your web browser and allow you to interact with the workspace by modifying files or running terminal commands.

For .NET web apps you can also run the application and access it remotely. This works by Gitpod proxying the opened ports to a URL you can use to access it, however by default the .NET Core/.NET 5+ Kestral server will only respond to requests from localhost.

To allow Kestral to respond to the requests through the Gitpod proxy, the launch settings for the .NET web app will need to be amended. This can be done by adding the urls environment variable and providing a value of http://0.0.0.0:5001. This will tell Kestral to respond to all requests on port 5001. 5001 is the default port for an ASP.NET 5+ web app over HTTPS. You will need to use a different port if you have changed this.

You can find a complete sample with the configuration already in place at the Gitpod .NET repository on GitHub. This is the standard Razor Pages template with a Gitpod configuration file specifying the .NET workspace image and modified launch settings with the added environment variable.


Found something helpful?

If you've found something useful, I'd be very thankful for a coffee.
Buy Me A Coffee