Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?

C#
Dim computer_name() As String
 computer_name =  split(System.Net.Dns.GetHostEntry(Request.ServerVariables("remote_addr")).HostName, ".")
   Me.lblcompname.Text = computer_name(0).ToUpper



Pls help me

Maideen
Posted
Updated 11-Oct-13 18:52pm
v4

C#
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());
    }
}

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
 
Share this answer
 
Comments
Maideen Abdul Kader 14-Oct-13 1:56am    
Thanks Mr.Tatraja
Solved the problem
Thanks Mr. Thatraja
Solved My Problem...

Maideen
 
Share this answer
 
Comments
André Kraak 13-Oct-13 3:05am    
I think you intended to comment to a solution, but created a solution instead.

If you have a question about or comment on a given solution use the "Have a Question or Comment?" option beneath the solution. When using this option the person who gave the solution gets an e-mail message and knows you placed a comment and can respond if he/she wants.
Please move the content of this solution to the solution you are commenting on and remove the solution.

Thank you.
Maideen Abdul Kader 14-Oct-13 1:56am    
thanks. Mr.andre...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900