Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is specifying the listening HTTP port via UseUrls the correct way?

I have successfully deployed an asp.net core mvc to windows iot core on my raspberry pi 3.

I am not sure whether specifying the listening HTTP port via invoking UseUrls as shown in the following snippet is the correct way.

namespace winiotrasp
{
    public class Program
    {
        // ... others ...

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseUrls("http://*:80")
                .Build();
    }
}

Questions

Is specifying the listening HTTP port via UseUrls the correct way?

Note that If I don't specify as shown above, the default setting is http://localhost:5000 which makes the web server inaccessible from other devices.

like image 635
In Vladimir Putin We Trust Avatar asked Sep 24 '17 21:09

In Vladimir Putin We Trust


1 Answers

Yes, it is the correct way.The UseUrls method is for indicates the IP addresses or host addresses with ports and protocols that the server should listen on for requests. Please reference Hosting in ASP.NET Core. If you don't specify the the IP addresses or host addresses with ports, you can use cmdlet $env:ASPNETCORE_URLS="http://0.0.0.0:5000" to change the default setting, then run the web server and it will be inaccessible from other devices.

like image 79
Michael Xu Avatar answered Oct 07 '22 00:10

Michael Xu