如何获取访问IIS Web应用程序的客户端PC名称?

时间:2014-11-03 19:27:24

标签: asp.net vb.net iis

这是一个部署在iis上的Vb.NET 4.0框架Web应用程序。

我的页面上有一个欢迎标签,它会根据客户端PC名称显示不同的消息。问题是我要么获取网络服务器主机名/ IP地址,要么收到错误“没有这样的主机已知”

以下是针对各种错误消息尝试的不同方法。

感谢您寻找

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Try

        'No such host is known Error
        'WelcomeMessage.Text = System.Net.Dns.GetHostEntry(Request.UserHostName).ToString
        'WelcomeMessage.Text = (Dns.GetHostEntry(Request.ServerVariables("remote_addr")).HostName.ToString)
        'WelcomeMessage.Text = System.Net.Dns.GetHostEntry(Request.ServerVariables("REMOTE_HOST")).HostName

        'I receive the IPv6 ID
        'WelcomeMessage.Text = Request.UserHostAddress

        'I receive the web Server ID
        'WelcomeMessage.Text = System.Net.Dns.GetHostName()\

    Catch ex As Exception
        WelcomeMessage.Text = ex.Message

    End Try


End Sub

0 个答案:

没有答案