I have a webpage that loads, does some calculations and then does a JavaScript redirect to another webpage. It looks something like this:
http://www.mysite.com/startpage.html
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
$(document).ready(function() {
window.location = "http://www.mynewurl.com";
});
</head>
<body>
Something
</body>
</html>
Now I have an asp.net MVC app that loads a WebBrowser control and my goal is to be able to retrieve http://www.mynewurl.com
from within my C# WebBrowser control.
My WebBrowser code looks like:
WebBrowser webBrowser = new WebBrowser
{
ScrollBarsEnabled = false,
Size = new Size(Width, Height),
ScriptErrorsSuppressed = true
};
webBrowser.NewWindow += WebBrowserNewWindow;
webBrowser.Navigate("http://www.mysite.com/startpage.html");
//wait for it to load
while (webBrowser.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
Uri myUrl = webBrowser.Url; //This is how I have been trying to get it.
So when I load my webBrowser control I send it to http://www.mysite.com/startpage.html
. It does a javascript redirect to http://www.mynewurl.com
. I want to somehow capture that url in my c# code.
Any ideas on how I can achieve this?