获取URL:
通过ASPNET获取如果测试的url地址是x 结果如下
RequestApplicationPath: /testweb RequestCurrentExecutionFilePath: /testweb/defaultaspx RequestFilePath: /testweb/defaultaspx RequestPath: /testweb/defaultaspx RequestPhysicalApplicationPath: E:\WWW\testweb\ RequestPhysicalPath: E:\WWW\testweb\defaultaspx RequestRawUrl: /testweb/defaultaspx RequestUrlAbsolutePath: /testweb/defaultaspx RequestUrlAbsoluteUrl: x RequestUrlHost: RequestUrlLocalPath: /testweb/defaultaspx
通过JS获取
<table width=% cellpadding= cellspacing= border= >
<script>
thisURL = documentURL;
thisHREF = documentlocationhref;
thisSLoc = selflocationhref;
thisDLoc = documentlocation;
strwrite = <tr><td valign=top>thisURL: </td><td>[ + thisURL + ]</td></tr>
strwrite += <tr><td valign=top>thisHREF: </td><td>[ + thisHREF + ]</td></tr>
strwrite += <tr><td valign=top>thisSLoc: </td><td>[ + thisSLoc + ]</td></tr>
strwrite += <tr><td valign=top>thisDLoc: </td><td>[ + thisDLoc + ]</td></tr>
documentwrite( strwrite );
</script>
thisDLoc = documentlocation; <BR>
thisURL = documentURL; <BR>
thisHREF = documentlocationhref; <BR>
thisSLoc = selflocationhref;<BR>
<script>
thisTLoc = toplocationhref;
thisPLoc = parentdocumentlocation;
thisTHost = toplocationhostname;
thisHost = locationhostname;
strwrite = <tr><td valign=top>thisTLoc: </td><td>[ + thisTLoc + ]</td></tr>
strwrite += <tr><td valign=top>thisPLoc: </td><td>[ + thisPLoc + ]</td></tr>
strwrite += <tr><td valign=top>thisTHost: </td><td>[ + thisTHost + ]</td></tr>
strwrite += <tr><td valign=top>thisHost: </td><td>[ + thisHost + ]</td></tr>
documentwrite( strwrite );
</script>
thisTLoc = toplocationhref; <BR>
thisPLoc = parentdocumentlocation; <BR>
thisTHost = toplocationhostname; <BR>
thisHost = locationhostname;<BR>
<script>
tmpHPage = thisHREFsplit( / );
thisHPage = tmpHPage[ tmpHPagelength ];
tmpUPage = thisURLsplit( / );
thisUPage = tmpUPage[ tmpUPagelength ];
strwrite = <tr><td valign=top>thisHPage: </td><td>[ + thisHPage + ]</td></tr>
strwrite += <tr><td valign=top>thisUPage: </td><td>[ + thisUPage + ]</td></tr>
documentwrite( strwrite );
</script><tr><td>
获取IP
ASPNET中获取
获取服务器的IP地址
using SystemNet;
string myIPmyMac;
SystemNetIPAddress[] addressList = DnsGetHostByName(DnsGetHostName())AddressList;
if ( addressListLength>)
{
myIP = addressList[]ToString();
myMac = addressList[]ToString();
}
else
{
myIP = addressList[]ToString();
myMac = 没有可用的连接
}
myIP地址就是服务器端的ip地址
获取客户端的ip地址可以使用
//获取登录者ip地址
string ip = RequestServerVariables[REMOTE_ADDR]ToString();
通过JS获取
<html>
<head>
<title></title>
<meta httpequiv=ContentType content=text/html; charset=gbk>
</head>
<body>
<object classid=CLSID:ACBDBDB id=locator ></object>
<object classid=CLSID:CAFdAACCFBC id=foo ></object>
<form name=myForm>
<br>MAC地址<input type=text name=macAddress>
<br>IP地址<input type=text name=ipAddress>
<br>主机名<input type=text name=hostName>
</form>
</body>
</html>
<script language=javascript>
var sMacAddr=;
var sIPAddr=;
var sDNSName=;
var service = locatorConnectServer();
serviceSecurity_ImpersonationLevel=;
serviceInstancesOfAsync(foo Win_NetworkAdapterConfiguration);
</script>
<script FOR=foo EVENT=OnObjectReady(objObjectobjAsyncContext) LANGUAGE=JScript> if(objObjectIPEnabled != null && objObjectIPEnabled != undefined && objObjectIPEnabled == true){ if(objObjectIPEnabled && objObjectIPAddress() !=null && objObjectIPAddress() != undefined) sIPAddr = objObjectIPAddress();
if(objObjectMACAddress != null &&objObjectMACAddress != undefined) sMacAddr = objObjectMACAddress;
if(objObjectDNSHostName != null &&objObjectDNSHostName != undefined) sDNSName = objObjectDNSHostName;
}
</script>
<script FOR=foo EVENT=OnCompleted(hResultpErrorObject pAsyncContext) LANGUAGE=JScript>
myFormmacAddressvalue=sMacAddr;
myFormipAddressvalue=sIPAddr;
myFormhostNamevalue=sDNSName;
</script>