Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai All
How to check server pc or client pc when using web site ? in page load event i need to check server pc or client pc,if it server pc i enable textbox and label,if not i disable textbox and label,

need to check in 3 condition in a link
1.with ip address like http://192.168.0.4/web/login.aspx
2.with localhost like http://localhost/web/login.aspx
3.with machine name like http://admin-PC/web/login.aspx

in above 3 condition,it will wotk on localhost basis and code is
VB
' Dim SERVERIP As String
 Dim CLIENTIP As String = String.Empty
 'Dim ipEntry As IPHostEntry = Dns.GetHostByName(Dns.GetHostName())
' Dim IpAddr As IPAddress() = ipEntry.AddressList
 'SERVERIP = IpAddr(0).ToString()

 CLIENTIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")'here i get server or client if it server i get ::1,then i enable textbox and label,if it client i will get full ip addres ,then i will disable textbox and label.
 If CLIENTIP = "" Then
     CLIENTIP = Request.ServerVariables("REMOTE_ADDR")
 End If

 If (CLIENTIP = "::1") Then
     txtBrowseFolder.Enabled = True
     btnwatchpath.Enabled = True
 Else
     txtBrowseFolder.Enabled = False
     btnwatchpath.Enabled = False
 End If


the above correctly work if it use localhost in an a link,if it is ip address or machine name not work.

note : pls think client server machinsim
publish copy available in server system,if anybody open link need to check whether client or server pc,if it server pc enable controls it not disable controls.
Pls reply me asap


Regards
Aravind
Posted
Updated 28-Nov-13 19:12pm
v2

1 solution

Hi
You need to run client side code same as VBScript on your machine however you shoulod make a list of your computers(clients and servers) and used this vbscript for getting name of currently computer application is ruining on:

<script language="vbscript"> 
<!--

Function SetComputerName
    Set objNetwork = CreateObject("WScript.Network") 
    NAME=objNetwork.computername
    Document.Forms("form1").Elements("computername").Value = NAME
End Function

SetComputerName()

//--> 

</script> 


after that you can decide about type of your computer follow of computer list, however you can get IP Address with checking computer name on DNS thus if you want to the make a additional conditions it is possible ;-)

these links can be useful:
http://www.robvanderwoude.com/vbstech_network_names_computer.php[^]
http://www.activexperts.com/activmonitor/windowsmanagement/scripts/networking/client/retrieving/[^]

Best Regards
 
Share this answer
 
Comments
Aravindba 29-Nov-13 1:15am    
thank u for ur reply pls think client server machinsim
publish copy available in server system,if anybody open link need to check whether client or server pc,if it server pc enable controls it not disable controls.
Aydin Homay 29-Nov-13 1:45am    
in web application we have one sever(IIS or Apache lab lab lab) and clients, actually client sent request to server and server response to client so could you tell what is your meaning of term server?
Aravindba 20-Dec-13 2:37am    
yes,correct,but sometime can run in server machine itself,that time how u find server or client ?
Aydin Homay 20-Dec-13 5:40am    
You can have more solutions for identify server/client one of the famous solution is detecting Operation System or IP table information or some other solutions oriented with asp and IIS services

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