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;
C#获取当前页面的url的更多相关文章
- 转载: js jquery 获取当前页面的url,获取frameset中指定的页面的url(有修改)
转载网址:http://blog.csdn.net/bestlxm/article/details/6800077 js jquery 怎么获取当前页面的url,获取frameset中指定的页面的ur ...
- js获取当前页面的URL并且截取?之后的数据,返回json
js获取当前页面的URL并且截取'?'之后的数据,返回json格式的数据 最近想要把学到的东西整理一下,以后方便查找,也是一种自我累积,如果有错误或者更好的,欢迎提出! 这篇文档主要是写关于获取页面的 ...
- js获取当前页面的url网址信息小汇总
在WEB开发中,时常会用到javascript来获取当前页面的url网址信息,在这里是我的一些获取url信息的小总结. 下面我们举例一个URL,然后获得它的各个组成部分:http://i.cnblog ...
- 获取当前页面的URL信息
以前在做网站的时候,经常会遇到当前页的分类高亮显示,以便让用户了解当前处于哪个页面.之前一直是在每个不同页面写方法.工程量大,也不便于修改.一直在想有什么简便的方法实现.后来在网上查到可以用获取当前U ...
- react获取当前页面的url参数
react获取当前页面的url参数,必须在url路由对应的组件上获取,在子组件上获取不到,为undefined,获取形如 /news/:id 的后面的参数 id this.props.match. ...
- 原生php如何获取当前页面的url
原生php如何获取当前页面的url? //php获取当前访问的完整url地址 function get_current_url(){ $current_url='http://'; if(isset( ...
- 用js获取当前页面的url的相关信息方法
当前页面对应的URL的一些属性: ( http://bbs.xxx.net/forum.php?mod=viewthread&tid=2709692&page=1&extra= ...
- 微信小程序-怎么获取当前页面的url
getCurrentPages() 函数用于获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面. https://developers.weixin.qq.com ...
- 微信小程序怎么获取当前页面的url
使用getCurrentPages可以获取当前加载中所有的页面对象的一个数组,数组最后一个就是当前页面. var pages = getCurrentPages() //获取加载的页面 var cur ...
随机推荐
- 安装Git
因为我的开发环境是Windows,那么在windows下安装Git就简单很多了.首先在,从http://msysgit.github.io/下载Git的安装程序,然后按默认选项安装即可. 安装成功之后 ...
- 用C语言操纵Mysql
以下代码块是用来连接数据库的通讯过程,要连接MYSQL,必须建立MYSQL实例,通过mysql_init初始化方能开始进行连接. typedef struct st_mysql { NET net; ...
- linux添加字体的过程
只说一下过程, 至于具体的原理还没搞明白. 1. 首先你要有字体文件,ttf或者ttc格式的均可以 我们可以从windows的 C:\WINDOWS\Fonts\ 这个目录下的字体文件复制出来,例如我 ...
- jboss-as 目录结构(转)
jboss-as 目录结构(Directory Structure) Directory Description bin Contains startup, shutdown and other sy ...
- oracle中的函数
ORACLE中函数 Oracle已经内建了许多函数,不同的函数有不同的作用和用法,有的函数只能作用在一个记录行上,有的能够作用在多个记录行上,不同的函数可能处理不同的数据类型.常见的 ...
- OpenStack 界面开发中response.body的中文编码问题
Contents [hide] 1 问题的引入= 1.1 解决办法 2 用户限制输入中文 3 不限制用户输入,呈现上修改 问题的引入= G在我们创建虚拟机的时候,会设置虚拟机的名称,描述,如果没有限制 ...
- iOS,破冰!
首发:个人博客,更新&纠错&回复 iOS,破冰! 今年学的技术,以iOS自学为成本最高昂:花几千块买了台mac mini电脑,又前后买了6本书籍,从头到尾是30天时间,当然,这30天里 ...
- 文字处理控件TX Text Control X10独家揭秘(一):数据源自动处理
TX Text Control即将发布的X10版本,将升级重点还是放到了其比较优势的流式布局报表设计和生成上.慧都获得了来自其开发商Text Control GmbH公司的一手资料,迫不及待的为大家带 ...
- MySQL OnlineDDL
参考资料: http://dev.mysql.com/doc/refman/5.6/en/innodb-create-index-overview.html http://www.mysqlperfo ...
- C# ZipHelper C#公共类 压缩和解压
关于本文档的说明 本文档基于ICSharpCode.SharpZipLib.dll的封装,常用的解压和压缩方法都已经涵盖在内,都是经过项目实战积累下来的 1.基本介绍 由于项目中需要用到各种压缩将文件 ...