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;

C#获取当前页面的url的更多相关文章

  1. 转载: js jquery 获取当前页面的url,获取frameset中指定的页面的url(有修改)

    转载网址:http://blog.csdn.net/bestlxm/article/details/6800077 js jquery 怎么获取当前页面的url,获取frameset中指定的页面的ur ...

  2. js获取当前页面的URL并且截取?之后的数据,返回json

    js获取当前页面的URL并且截取'?'之后的数据,返回json格式的数据 最近想要把学到的东西整理一下,以后方便查找,也是一种自我累积,如果有错误或者更好的,欢迎提出! 这篇文档主要是写关于获取页面的 ...

  3. js获取当前页面的url网址信息小汇总

    在WEB开发中,时常会用到javascript来获取当前页面的url网址信息,在这里是我的一些获取url信息的小总结. 下面我们举例一个URL,然后获得它的各个组成部分:http://i.cnblog ...

  4. 获取当前页面的URL信息

    以前在做网站的时候,经常会遇到当前页的分类高亮显示,以便让用户了解当前处于哪个页面.之前一直是在每个不同页面写方法.工程量大,也不便于修改.一直在想有什么简便的方法实现.后来在网上查到可以用获取当前U ...

  5. react获取当前页面的url参数

    react获取当前页面的url参数,必须在url路由对应的组件上获取,在子组件上获取不到,为undefined,获取形如  /news/:id  的后面的参数 id this.props.match. ...

  6. 原生php如何获取当前页面的url

    原生php如何获取当前页面的url? //php获取当前访问的完整url地址 function get_current_url(){ $current_url='http://'; if(isset( ...

  7. 用js获取当前页面的url的相关信息方法

    当前页面对应的URL的一些属性: ( http://bbs.xxx.net/forum.php?mod=viewthread&tid=2709692&page=1&extra= ...

  8. 微信小程序-怎么获取当前页面的url

    getCurrentPages() 函数用于获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面. https://developers.weixin.qq.com ...

  9. 微信小程序怎么获取当前页面的url

    使用getCurrentPages可以获取当前加载中所有的页面对象的一个数组,数组最后一个就是当前页面. var pages = getCurrentPages() //获取加载的页面 var cur ...

随机推荐

  1. String.Format数字格式化参考

    String.Format数字格式化输出 {0:N2} {0:D2} {0:C2} (转) 数字 {0:N2} 12.36 数字 {0:N0} 13 货币 {0:c2} $12.36 货币 {0:c4 ...

  2. Logic and Fault simulation

    fault simulation是指对fault circuit的simulation,来locate manufacturing defects并且进行fault diagnosis. logic ...

  3. wc移植sae笔记

    1.wc移植到sae---上传图片 ①先看profile.ptl.html中的ajax代码修改functions.js中G_BASE_URL的值.在这里我先写死成->'http://2.idan ...

  4. C++字符串和string类介绍

    一.C风格字符串 ◆ 1.字符串是用字符型数组存储的,字符串要求其尾部以'\0'作为结束标志.如:    char string[ ]="C++ programming language&q ...

  5. ReportingService 通过RowNumber函数获取行号和生成隔行变色样式

    以前一直没有搞明白SSRS里面的RowNumber函数到底该怎么用,所以一直没有很好的办法在SSRS中的表格上实现隔行变色的样式,实现隔行变色的关键就是获取表格中每一行的行号.在最近了解了下这个函数, ...

  6. Maven(一)

    Maven学习总结(一)——Maven入门 一.Maven的基本概念 Maven(翻译为"专家","内行")是跨平台的项目管理工具.主要服务于基于Java平台的 ...

  7. android简单的夜间模式

    现在android项目values下打 attrs.xml <?xml version="1.0" encoding="utf-8"?> <r ...

  8. linux设备驱动归纳总结(七):1.时间管理与内核延时【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-100005.html linux设备驱动归纳总结(七):1.时间管理与内核延时 xxxxxxxxxxx ...

  9. (转)java线程安全问题之静态变量、实例变量、局部变量

    java多线程编程中,存在很多线程安全问题,至于什么是线程安全呢,给出一个通俗易懂的概念还是蛮难的,如同<java并发编程实践>中所说: 写道 给线程安全下定义比较困难.存在很多种定义,如 ...

  10. shell中读写mysql数据库

    本文介绍了如何在shell中读写mysql数据库.主要介绍了如何在shell 中连接mysql数据库,如何在shell中创建数据库,创建表,插入csv文件,读取mysql数据库,导出mysql数据库为 ...