你如何使用ASP.net获取计算机的IP地址? [英] How do you get the IP address of a computer using ASP.net?

查看:77
本文介绍了你如何使用ASP.net获取计算机的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用ASP.net获取计算机的IP地址?

我尝试了Request.UserHostAddress并且它不起作用。


我获取

请求获得类型的许可

''System.Security.Permissions.UIPermission,mscorlib,Version = 2.0.0.0,

Culture =中立,PublicKeyToken = b77a5c561934e089''失败。


应该可以,因为很多网站都可以显示你的IP地址。

解决方案

您没有阅读并应用其他人告诉您的内容。你无论如何都不能依赖于获取IP地址。例如,AOL用户总是会显示相同的IP,因为它们通过代理。您希望

与IP有什么关系?希望没有像用户个性化那样幼稚

或类似的东西。


使用以下内容创建一行test.aspx:


<%Response.Write(Request.ServerVariables(" REMOTE_HOST"))%>


" sirfunusa" < SI ******* @ hotmail.com>在消息中写道

新闻:11 ********************* @ u72g2000cwu.googlegro ups.com ...
< blockquote class =post_quotes>你希望用IP做什么?希望没有像用户个性化或类似的那样天真。




非常正确!任何认为任何

浏览器提供给任何服务器的IP地址甚至*远程*准确的人都被严重欺骗......


看看我的意思?


How do you get the IP address of a computer using ASP.net?
I tried Request.UserHostAddress and it does not work.

I get
Request for the permission of type
''System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'' failed.

It should be possible, because many web site can show you your ip address.

解决方案

You did not read and apply what others have told you. You can never
rely on getting the ip address anyway. AOL users for example, always
will show the same IP, since they go through a proxy. What do you hope
to do with the IP? Hopefully nothing as naive as user personalization
or similar.

Create a one-line test.aspx with the following:

<% Response.Write (Request.ServerVariables("REMOTE_HOST")) %>


"sirfunusa" <si*******@hotmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...

What do you hope to do with the IP? Hopefully nothing as
naive as user personalization or similar.



Quite right! Anyone who believes that the the IP address supplied by any
browser to any server is even *remotely* accurate is seriously deluded...


See what I mean?


这篇关于你如何使用ASP.net获取计算机的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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