本实例的测试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
以上就是C#获取当前页面的URL示例代码的内容,更多相关内容请关注PHP中文网(www.php.cn)!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1431930.html
微信扫一扫
支付宝扫一扫