快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

asp.net获取URL和IP地址

获取URL:

    1、通过ASP.NET获取如果测试的url地址是http://www.test.com/testweb/default.aspx, 结果如下:

    Request.ApplicationPath: /testweb Request.CurrentExecutionFilePath: /testweb/default.aspx Request.FilePath: /testweb/default.aspx Request.Path: /testweb/default.aspx Request.PhysicalApplicationPath: E:\WWW\testweb\ Request.PhysicalPath: E:\WWW\testweb\default.aspx Request.RawUrl: /testweb/default.aspx Request.Url.AbsolutePath: /testweb/default.aspx Request.Url.AbsoluteUrl: http://www.test.com/testweb/default.aspx Request.Url.Host: www.test.com Request.Url.LocalPath: /testweb/default.aspx

    2、通过JS获取

   

  1. <table width=100cellpadding=0 cellspacing=0 border=0 > 
  2.  
  3.     <script> 
  4.  
  5.     thisURL = document.URL;  
  6.  
  7.     thisHREF = document.location.href;  
  8.  
  9.     thisSLoc = self.location.href;  
  10.  
  11.     thisDLoc = document.location;  
  12.  
  13.     strwrite = "<tr><td valign=top>thisURL: </td><td>[" + thisURL + "]</td></tr>"  
  14.  
  15.     strwrite += "<tr><td valign=top>thisHREF: </td><td>[" + thisHREF + "]</td></tr>"  
  16.  
  17.     strwrite += "<tr><td valign=top>thisSLoc: </td><td>[" + thisSLoc + "]</td></tr>"  
  18.  
  19.     strwrite += "<tr><td valign=top>thisDLoc: </td><td>[" + thisDLoc + "]</td></tr>"  
  20.  
  21.     document.write( strwrite );  
  22.  
  23.     </script> 
  24.  
  25.     thisDLoc = document.location; <BR> 
  26.  
  27.     thisURL = document.URL; <BR> 
  28.  
  29.     thisHREF = document.location.href; <BR> 
  30.  
  31.     thisSLoc = self.location.href;<BR> 
  32.  
  33.     <script> 
  34.  
  35.     thisTLoc = top.location.href;  
  36.  
  37.     thisPLoc = parent.document.location;  
  38.  
  39.     thisTHost = top.location.hostname;  
  40.  
  41.     thisHost = location.hostname;  
  42.  
  43.     strwrite = "<tr><td valign=top>thisTLoc: </td><td>[" + thisTLoc + "]</td></tr>"  
  44.  
  45.     strwrite += "<tr><td valign=top>thisPLoc: </td><td>[" + thisPLoc + "]</td></tr>"  
  46.  
  47.     strwrite += "<tr><td valign=top>thisTHost: </td><td>[" + thisTHost + "]</td></tr>"  
  48.  
  49.     strwrite += "<tr><td valign=top>thisHost: </td><td>[" + thisHost + "]</td></tr>"  
  50.  
  51.     document.write( strwrite );  
  52.  
  53.     </script> 
  54.  
  55.     thisTLoc = top.location.href; <BR> 
  56.  
  57.     thisPLoc = parent.document.location; <BR> 
  58.  
  59.     thisTHost = top.location.hostname; <BR> 
  60.  
  61.     thisHost = location.hostname;<BR> 
  62.  
  63.     <script> 
  64.  
  65.     tmpHPage = thisHREF.split( "/" );  
  66.  
  67.     thisHPage = tmpHPage[ tmpHPage.length-1 ];  
  68.  
  69.     tmpUPage = thisURL.split( "/" );  
  70.  
  71.     thisUPage = tmpUPage[ tmpUPage.length-1 ];  
  72.  
  73.     strwrite = "<tr><td valign=top>thisHPage: </td><td>[" + thisHPage + "]</td></tr>"  
  74.  
  75.     strwrite += "<tr><td valign=top
顶(1)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论