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. sql 通过游标 拆分xml结构

    -----------------------定义游标变量------------------------------------------  DECLARE @propertyid INT   D ...

  2. paper 34 :常见函数的举例(更新ing)2

    在研究opencv,不是很难,但是需要换种思维来认知这个C/C++为编程函数的开源代码库,OK,我现在还是总结一些常用MATLAB的函数,随时更新,下一阶段就是opencv方面的认知了! 1.std ...

  3. drds 分库表的创建速记

    关键词 :dbpartition by hash(`INVESTOR_APPLY_ID`) 格式 :dbpartition by hash(分库字段) 创建例子: CREATE TABLE `BB_J ...

  4. 夺命雷公狗—angularjs—18—angularjs的事件

    对于一款前端框架,提起事件,很容易让人联想到DOM事件,比如说鼠标点击以及页面滚动等.但是我们这里说的angular中的事件和DOM事件并不是一个东西. 事件的发布 我们可以通过 $emit() 以及 ...

  5. PAT乙级 1014. 福尔摩斯的约会 (20)

    1014. 福尔摩斯的约会 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 大侦探福尔摩斯接到一张奇怪的 ...

  6. 搞不定linux下的无线网卡驱动的权宜之计

    毕竟windows用了这么些年了,对windows下的一些东西也比较熟悉,还有就是windows的软件方式比较傻瓜. 在linux下搞不定无线网卡啊,幸亏有甲骨文的virtualbox,咱虚拟一个xp ...

  7. Windows应用层网络模块扫盲

           说到Windows应用层网络通信不得不提winsock,winsock是工作在TCP/IP层的应用层(TCP/IP层分为主机到网络层[比特].网络互联层[数据帧].传输层[数据包].应用 ...

  8. 什么是商业智能BI和实施BI的解决方案【转】

    商业智能,或BI,是一种统称,泛指用于对一个企业的原始数据进行分析的各种各样的软件系统.商业智能(BI)是由若干相关的活动组成的领域,包括数据挖掘,在线分析处理,查询和报表. 企业用商业智能(BI)来 ...

  9. android 学习随笔二十四(动画:帧动画)

    帧动画,一张张图片不断的切换,形成动画效果 * 在drawable目录下定义xml文件,子节点为animation-list,在这里定义要显示的图片和每张图片的显示时长 * FrameAnimatio ...

  10. db.properties

    jdbc.driverclass=oracle.jdbc.driver.OracleDriverjdbc.url=jdbc:oracle:thin:@192.168.201.192:1521:orcl ...