Determine port in asp.net core

自闭症网瘾萝莉.ら 提交于 2020-01-21 09:01:28

问题


I want to make some microservices with asp.net core (Web Api) For service discovery I want use Consul where I must register the services via the HTTP API including IP and port.

My question is: How can I know which port is used within in a service? Is there a way to determine the used port via code?


回答1:


Yeah, Use HttpContext.Connection.LocalPort to get the local port that the server is listening on.



来源:https://stackoverflow.com/questions/41165303/determine-port-in-asp-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!