Test URL of this example: http://www.mystudy.cn/web/index.aspx
1. Get the URL of the current page through C
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. Through Javascript Get the URL of the current page
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
The above is the content of the C# Get the URL of the current page sample code. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!