I Installed .NET Core SDK v3.1
on an Ubuntu VPS,
and I am now experimenting with ASP.NET Core
projects.
I use
dotnet new webapp -o <ProjectName> --no-https
to create an ASP.NET Core project,
and
dotnet run
to run it, using .NET Core's built-in Web Server.
I have a small problem, which is the fact that .NET Core's built-in Web Server binds to IP 127.0.0.1
(localhost),
and not to the Public IP of my VPS.
This means that I cannot connect to my ASP.NET Core project from a browser on a remote computer, only from a browser on that VPS.
If instead of binding to 127.0.0.1
the Web Server would bind to 0.0.0.0
,
then it will be good, since 0.0.0.0
means "All Network Interfaces", and not just the localhost IP.
After searching in Google, people recommend to go to the project's folder,
then enter the Properties folder,
and there, to Edit a file called launchSettings.json
.
In that file, we need to change:
"applicationUrl": "http://localhost:5000"
to
"applicationUrl": "http://0.0.0.0:5000"
After doing this and re-running the project, the problem is solved,
and I can connect to the web server from a remote computer.
So this solution works,
yet I have 1 problem with it:
It requires editing every project's launchSettings.json
file.
I am looking for a solution that does not require changing every project for this,
but more like changing the Web Server's settings, once..
Does such a solution exist?
For example some Settings file for the Web Server, that defined which IP and Port to bind to,
or If not that, then maybe there's some Template for ASP.NET Core projects, and I can go to that Template's folder, and then edit there the launchSettings.json
file of the Template,
so all new ASP.NET Core projects that will be created from that moment on, will be created with the right IP (0.0.0.0).
Any solution that can be done Once, instead of Every Time, will be great.