且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取ASP.NET中客户端计算机的IP地址

更新时间:2022-10-25 08:14:55

使用以下内容: -



 HttpRequest currentRequest = HttpContext.Current 。请求; 
字符串 clientIP = currentRequest.ServerVariables [ REMOTE_ADDR];


您尝试过什么?我什么都没想:(

如何在asp.net(C#)中获取客户端IP。 [ ^ ]


Request.UserHostAddress为您提供客户端的IP地址

How to get IP address of client machine in ASP.NET?

[edit(zorgoz): case corrected]

Use the following :-

HttpRequest currentRequest = HttpContext.Current.Request;
String    clientIP = currentRequest.ServerVariables["REMOTE_ADDR"];


What have you tried? I suppose nothing :(
How to get client IP in asp.net(C#).[^]


Request.UserHostAddress gives you the client''s IP address