Is specifying the listening HTTP port via UseUrls the correct way?
Asked Answered
F

1

17

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.

Flashlight answered 24/9, 2017 at 21:46 Comment(0)
M
12

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.

Mcclurg answered 25/9, 2017 at 3:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.