手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >在asp.net中获取当前页面的URL的方法(推荐)
在asp.net中获取当前页面的URL的方法(推荐)
摘要:获取Url的方法有两种,通过后台获得或通过前面js获得,如下:1、通过C#获取当前页面的URLstringurl=Request.Url.A...

获取Url的方法有两种,通过后台获得或通过前面js获得,如下:

1、通过C#获取当前页面的URL

string url = Request.Url.AbsoluteUri; //结果: http://www.jb51.net/web/index.aspx

string host = Request.Url.Host; //结果:www.jb51.net

string rawUrl = Request.RawUrl; //结果:/web/index.aspx

string localPath = Request.Url.LocalPath; //结果:/web/index.aspx

2、通过Javascript获取当前页面的URL

var url = document.URL; //结果:http://www.jb51.net/web/index.aspx

var href = document.location.href; //结果:http://www.jb51.net/web/index.aspx

var host = location.hostname; //结果:www.jb51.net

以上就是小编为大家带来的在asp.net中获取当前页面的URL的方法(推荐)的全部内容了,希望对大家有所帮助,多多支持查字典教程网~

【在asp.net中获取当前页面的URL的方法(推荐)】相关文章:

ASP.net中md5加密码的方法

ASP.NET页面间的传值的几种方法

asp.net中List的使用方法

asp.net中获取远程网页的内容之一(downmoon原创)

asp.net WebForm页面间传值方法

asp.net学习中发现的比较完整的流程

asp.net为网页动态添加关键词的方法

在asp.net中实现datagrid checkbox 全选的方法

asp.net清空Cookie的两种方法

Asp.net清空cache禁用页面缓存的方法

精品推荐
分类导航