如何获取服务器IP地址(在C#/asp.net中)? [英] How to get the server IP Address (in C# / asp.net)?

查看:61
本文介绍了如何获取服务器IP地址(在C#/asp.net中)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有1行方法来获取服务器的IP地址?

Is there a 1 line method to get the IP Address of the server?

谢谢

推荐答案

Request.ServerVariables["LOCAL_ADDR"];

文档:

返回请求所在的服务器地址.这对于计算机上可能有多个IP地址绑定到计算机,并且您想找出请求所使用的地址,这一点很重要.

Returns the server address on which the request came in. This is important on computers where there can be multiple IP addresses bound to the computer, and you want to find out which address the request used.

这不同于与客户端计算机有关的远程地址.

This is distinct from the Remote addresses which relate to the client machine.

这篇关于如何获取服务器IP地址(在C#/asp.net中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆