本实例的测试url:http://www.mystudy.cn/web/index.aspx
1、通过c#获取当前页面的url
string url = Request.Url.AbsoluteUri; //结果: <a href="http://www.mystudy.cn/web/index.aspx" target="_blank">http://www.mystudy.cn/web/index.aspx</a> 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)!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号