Remotely connect to .net core self hosted web api

后端 未结 6 873
既然无缘
既然无缘 2020-12-29 02:11

I have a simple .net core web api with one action:

[Route(\"[action]\")]
public class APIController : Controller
{
    // GET api/values
    [HttpGet]
    pu         


        
6条回答
  •  情话喂你
    2020-12-29 02:35

    You can simply do the following to create your WebHost, this will allow remote connections to kestrel.

    var host = WebHost.CreateDefaultBuilder(args)
                    .UseUrls("http://0.0.0.0:80")
                    .UseStartup()
                    .Build();
    

    After using the following code I still wasn't able to access my API remotely, I had to disable the network adapters created by Docker in the windows control panel (Control Panel\Network and Internet\Network Connections)

提交回复
热议问题