简体   繁体   中英

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 ?

for example:

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

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM