客户计算机名称 [英] Client Computer Name
本文介绍了客户计算机名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好b $ b
我在网络表单中使用下面的代码,它运行正常。如何将此代码放在class.vb文件中并调用许多asp.net页面?
Hi
I am using below code in my webform, it work fine. How can I put this code in class.vb file and call in many asp.net pages?
Dim computer_name() As String
computer_name = split(System.Net.Dns.GetHostEntry(Request.ServerVariables("remote_addr")).HostName, ".")
Me.lblcompname.Text = computer_name(0).ToUpper
请帮助我
Maideen
Pls help me
Maideen
推荐答案
public static class ClsUtils
{
public static string GetClientComputerName()
{
return System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables("remote_addr")).HostName;
}
}
public class ClsTest
{
public static void Main()
{
Console.WriteLine(ClsUtils.GetClientComputerName());
}
}
下面是转换器转换的VB.NET版本,如果你想要改变
Below is VB.NET version converted by Converter, Do changes if you want
Public NotInheritable Class ClsUtils
Private Sub New()
End Sub
Public Shared Function GetClientComputerName() As String
Return System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables("remote_addr")).HostName
End Function
End Class
Public Class ClsTest
Public Shared Sub Main()
Console.WriteLine(ClsUtils.GetClientComputerName())
End Function
End Class
谢谢Thatraja先生
解决了我的问题...
Maideen
Thanks Mr. Thatraja
Solved My Problem...
Maideen
这篇关于客户计算机名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文