C#获取当前页面的url

C#获取当前页面的url

         string a=   Request.ApplicationPath;            //   /
         string b = Request.CurrentExecutionFilePath;    //   /WebForm1.aspx
         string c = Request.FilePath;                    //   /WebForm1.aspx
         string d = Request.PhysicalApplicationPath;    //    c:\users\纯访\documents\visual studio 2013\Projects\WebApplication4\WebApplication4\ 
         string ee = Request.RawUrl;                    //    /WebForm1.aspx  
         string f = Request.Url.AbsolutePath;           //    /WebForm1.aspx 
         string g = Request.Url.AbsoluteUri;           //     http://localhost:7251/WebForm1.aspx
         string h = Request.Url.Host;                  //     localhost 
         string i = Request.Url.LocalPath;             //     /WebForm1.aspx

JS 获取当前页面的url

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script>  
        document.write("=============1==============================================="+ "<br>");
        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><br>"; 
        strwrite += "<tr><td valign=top>thisHREF: </td><td>[" + thisHREF + "]</td></tr><br>";
        strwrite += "<tr><td valign=top>thisSLoc: </td><td>[" + thisSLoc + "]</td></tr><br>";
        strwrite += "<tr><td valign=top>thisDLoc: </td><td>[" + thisDLoc + "]</td></tr><br>";
        document.write(strwrite);
        document.write("<br>"+"=============1===============================================" + "<br>");
    </script>
    <script> 
        document.write("<br>" + "=============2===============================================" + "<br>");
        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><br>";
        strwrite += "<tr><td valign=top>thisPLoc: </td><td>[" + thisPLoc + "]</td></tr><br>";
        strwrite += "<tr><td valign=top>thisTHost: </td><td>[" + thisTHost + "]</td></tr><br>";
        strwrite += "<tr><td valign=top>thisHost: </td><td>[" + thisHost + "]</td></tr><br>";
        document.write(strwrite);
        document.write("<br>" + "=============2===============================================" + "<br>");
    </script>
    <script>  
        document.write("<br>" + "=============3===============================================" + "<br>");
        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><br>";
        strwrite += "<tr><td valign=top>thisUPage: </td><td>[" + thisUPage + "]</td></tr><br>";
        document.write(strwrite);
        document.write("<br>" + "=============3===============================================" + "<br>");
    </script>

</head>
<body>
    <table width=100% cellpadding=0 cellspacing=0 border=0>
        <tbody>=================条目=============================</tbody><br />
        thisDLoc = document.location;
        <br>
        thisURL = document.URL;
        <br>
        thisHREF = document.location.href;
        <br>
        thisSLoc = self.location.href;
        <br>
       
        thisTLoc = top.location.href;
        <br>
        thisPLoc = parent.document.location;
        <br>
        thisTHost = top.location.hostname;
        <br>
        thisHost = location.hostname;
        <br>

<tr><td>
    </table>
</body>
</html>

效果:

=============1===============================================
thisURL: [http://localhost:7251/HtmlPage2.html]
thisHREF: [http://localhost:7251/HtmlPage2.html]
thisSLoc: [http://localhost:7251/HtmlPage2.html]
thisDLoc: [http://localhost:7251/HtmlPage2.html]

=============1===============================================

=============2===============================================
thisTLoc: [http://localhost:7251/HtmlPage2.html]
thisPLoc: [http://localhost:7251/HtmlPage2.html]
thisTHost: [localhost]
thisHost: [localhost]

=============2===============================================

=============3===============================================
thisHPage: [HtmlPage2.html]
thisUPage: [HtmlPage2.html]

=============3===============================================
=================条目=============================
thisDLoc = document.location; 
thisURL = document.URL; 
thisHREF = document.location.href; 
thisSLoc = self.location.href; 
thisTLoc = top.location.href; 
thisPLoc = parent.document.location; 
thisTHost = top.location.hostname; 
thisHost = location.hostname;