Introduce asp.net get the full URL of the current page of the square put, Icech made a function, directly use it.
private String GetPath ()
{
String strpath = "http://" + request.servervariables["http_host"] + request.servervariables["path_info"] + "?" + Request. servervariables["Query_string"];
if (Strpath.endswith ("?"))
{
strpath = strpath.substring (0, strpath.length-1);
}
return strpath;
}
----------------------------------------------
asp.net get URL and IP address
HttpContext.Current.Request.Url.ToString () is not reliable.
If the current URL is
Http://localhost/search.aspx?user=http://csharp.xdowns.com&tag=%BC%BC%CA%F5
The HttpContext.Current.Request.Url.ToString () gets the
http://localhost/search.aspxuser=http://csharp.xdowns.com&tag=¼¼ê& Otilde;
The correct approach is: HttpContext.Current.Request.Url.PathAndQuery1, get through asp.net
If the URL address for the test is http://www.test.com/testweb/default.aspx, the result is as follows:
Request.applicationpath:/testweb
Request.currentexecutionfilepath:/testweb/default.aspx
Request.filepath:/testweb/default.aspx
Request.path:/testweb/default.aspx
Request.physicalapplicationpath:e:/www/testwebrequest.physicalpath:e:/www/testweb/default.asp X
Request.rawurl:/testweb/default.aspx
Request.Url.AbsolutePath:/testweb/default.aspx
Request.url.absoluteurl:http://www.test.com/testweb/default.aspx
request.url.host:http://www.test.com/
Request.Url.LocalPath:/testweb/default.aspx
2, through JS access
<table width=100% cellpadding=0 cellspacing=0 border=0 >
<script>
Thisurl = document. URL;
Thishref = Document.location.href;
Thissloc = Self.location.href;
Thisdloc = document.location;
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>"
document.write (Strwrite);
</script>
Thisdloc = document.location; <BR>
Thisurl = document. URL; <BR>
Thishref = Document.location.href; <BR>
Thissloc = self.location.href;<br>
<script>
Thistloc = Top.location.href;
Thisploc = parent.document.location;
Thisthost = Top.location.hostname;
Thishost = Location.hostname;
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>"
document.write (Strwrite);
</script>
Thistloc = Top.location.href; <BR>
Thisploc = parent.document.location; <BR>
Thisthost = Top.location.hostname; <BR>
Thishost = location.hostname;<br>
<script>
Tmphpage = Thishref.split ("/");
Thishpage = tmphpage[Tmphpage.length-1];
Tmpupage = Thisurl.split ("/");
Thisupage = tmpupage[Tmpupage.length-1];
Strwrite = "<tr><td valign=top>thishpage: </td><td>[" + thishpage + "]</td></tr>"
Strwrite + = "<tr><td valign=top>thisupage: </td><td>[" + thisupage + "]</td></tr>"
document.write (Strwrite);
</script><tr><td>
=================
Get IP
1, ASP. NET to get
To obtain the server's IP address:
Using System.Net;
String Myip,mymac;
system.net.ipaddress[] AddressList = Dns.gethostbyname (Dns.gethostname ()). AddressList;
if (addresslist.length>1)
{
MyIP = addresslist[0]. ToString ();
Mymac = addresslist[1]. ToString ();
}
Else
{
MyIP = addresslist[0]. ToString ();
Mymac = "no connections available";
}
The MYIP address is the server-side IP address.
Gets the IP address of the client, which you can use
Get the IP address of the logged-on person
string ip = request.servervariables["REMOTE_ADDR"]. ToString ();
2, through JS access
<title></title>
<meta http-equiv= "Content-type" content= "text/html; CHARSET=GBK ">
<body>
<object classid= "Clsid:76a64158-cb41-11d1-8b02-00600806d9b6" id= "locator" style= "display:none;visibility": Hidden "></object>
<object classid= "clsid:75718c9a-f029-11d1-a1ac-00c04fb6c223" id= "foo" style= "Display:none;visibility:hidden" ></object>
<form name= "MyForm" >
<br/>mac Address: <input type= "text" name= "macAddress" >
<br/>ip Address: <input type= "text" Name= "IPAddress" >
<br/> Host Name: <input type= "text" name= "HostName" >
</form>
</body>
<script language= "JavaScript" >
var smacaddr= "";
var sipaddr= "";
var sdnsname= "";
var service = Locator. ConnectServer ();
Service. Security_. impersonationlevel=3;
Service. Instancesofasync (foo, ' Win32_NetworkAdapterConfiguration ');
</script>
<script for= "foo" event= "OnObjectReady (objobject,objasynccontext)" language= "JScript" >
if (objobject.ipenabled!= null && objobject.ipenabled!= "undefined" && objobject.ipenabled = = True) {
if (objobject.ipenabled && objobject.ipaddress (0)!=null && objobject.ipaddress (0)!= "undefined")
sipaddr = objobject.ipaddress (0);
if (objobject.macaddress!= null &&objobject.macaddress!= "undefined")
SMACADDR = objobject.macaddress;
if (objobject.dnshostname!= null &&objobject.dnshostname!= "undefined")
Sdnsname = Objobject.dnshostname;
}
</script>
<script for= "foo" event= "oncompleted (Hresult,perrorobject, Pasynccontext)" language= "JScript" >
MYFORM.MACADDRESS.VALUE=SMACADDR;
MYFORM.IPADDRESS.VALUE=SIPADDR;
Myform.hostname.value=sdnsname;
</script>