简体   繁体   中英

IP instead of localhost in URI

I am currently trying to create a valid link to a function of my API using this LOC:

Uri locationHeader = new Uri(Url.Link("GetUserById", new { id = user.Id }));

This returns the following:

http://localhost:53800/..../user/821105b1

However, as the link should be accessible from the network, I would need something like the following:

http://192.168.0.12:53800/..../user/821105b1

How can I get this result instead of the one with the localhost??

Thanks in advance!

Calling local libraries will only give you the local IP. You can call an external API like whatismyip or checkip to get the external IP. See here... https://stackoverflow.com/a/7838551

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