简体   繁体   中英

How to get url of navigated page 2 after button click of page 1 using WebBrowser Control in C#

I'm successfully navigating from www.url 1 .com to www.url 2 .com using webbrowser control but iam unable to get the url of navigated page ie, www.url 2 .com, using Webbrowser control in asp.net web application.

 Example:
I navigated to www.google.com

webBrowser.Navigate("http://www.google.com");

in that page i programatically given some text and click google search button as follow

HtmlElement textElement = webBrowser.Document.All.GetElementsByName("q")[0];
textElement.SetAttribute("value", "your text to search");
HtmlElement btnElement = webBrowser.Document.All.GetElementsByName("btnG")[0];
btnElement.InvokeMember("click");

After it navigated to [ https://www.google.co.in/?gfe_rd=cr&ei=dFMuWdWCHory8Afuwqog#q=your+text+to+search "]

Here my Question is How to get the that particular navigated url USING WEBBROWSER CONTROL IN c# i.e.,
**https://www.google.co.in/?gfe_rd=cr&ei=dFMuWdWCHory8Afuwqog#q=your+text+to+search"**

If you have any solution regarding this issue please share with me.

Thanks in advance.

由于页面是Web应用程序,因此使用href链接页面

<a href="https://www.google.com">Google </a>

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