用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > Net教程

C#获取当前页面的URL示例代码

时间:2015-01-29  来源:互联网  作者:佚名
本实例的测试URL:http://www.mystudy.cn/web/index.aspx

1、通过C#获取当前页面的URL
复制代码 代码如下:
string url = Request.Url.AbsoluteUri; //结果: http://www.mystudy.cn/web/index.aspx
string host = Request.Url.Host; //结果:www.mystudy.cn
string rawUrl = Request.RawUrl; //结果:/web/index.aspx
string localPath = Request.Url.LocalPath; //结果:/web/index.aspx

2、通过Javascript获取当前页面的URL
复制代码 代码如下:
var url = document.URL; //结果:http://www.mystudy.cn/web/index.aspx
var href = document.location.href; //结果:http://www.mystudy.cn/web/index.aspx
var host = location.hostname; //结果:www.mystudy.cn
来顶一下
返回首页
返回首页
推荐资讯
ASP.NET DropDownListCheckBox使用示例(解决回发问题) ASP.NET DropDownListCheckBox使用这个是根据LigerUI改的,解决了回发问题 资料地址 http://li
ASP.NET(C#) 读取EXCEL另加解决日期问题的方法分享 ASP.NET(C#) 读取EXCEL另加解决日期使用OLEDB可以对excel文件进行读取,我们只要把该excel文件作
相关文章
栏目更新
栏目热门