简体   繁体   中英

Determine port in asp.net core

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?

是的,使用HttpContext.Connection.LocalPort获取服务器正在侦听的本地端口。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM