[英]Get the current Url of web browser in C#
How can i get the current url (the opened url in web browser) in a text box ? 如何在文本框中获取当前URL(Web浏览器中打开的URL)?
for example: 例如:
webBrowser1.Url= new Uri("http://stackoverflow.com"); webBrowser1.Url = new Uri(“http://stackoverflow.com”);
and my browser opened the link !! 我的浏览器打开了链接!!
Now I want to get the url (http://stackoverflow.com) in a text box 现在我想在文本框中获取URL(http://stackoverflow.com)
regards. 问候。
yourTextBox.Text = webBrowser1.Url.ToString();
Result : http://localhost:1302/TESTERS/Default6.aspx
string url = HttpContext.Current.Request.Url.AbsoluteUri;
result : /TESTERS/Default6.aspx
string path = HttpContext.Current.Request.Url.AbsolutePath;
result : localhost
string host = HttpContext.Current.Request.Url.Host;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.