您好,欢迎访问一九零五行业门户网

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

本实例的测试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示例代码的内容。
其它类似信息

推荐信息