Zach Johnson
Zach Johnson

Reputation: 2237

How to get full URL from WebBrowser?

Hey guys I am using a webrower to get an access token to a website. The website redirects the webrower to a url containing the access token the redirected url looks like this:

http://www.myurl.us/#access_token=e0a81edc8de4886b7cc514bcb2b93e06666bd0d8&expires_in=3600&token_type=bearer&refresh_token=72e302438349b32a627b12c92b01060169443a9b&account_username=

in the DocumentCompleted event for my webrowser I am using this code:

Dim pretoken As String
    Dim url As String = WebBrowser1.Url.ToString
    If url.Contains("myurl.us") Then
        pretoken = WebBrowser1.Url.ToString
        MessageBox.Show(pretoken)
    End If

The message box only shows "myurl.us" and not the full url with the token i need. Anyway to get the whole url from the webbrowser?

Upvotes: 1

Views: 3624

Answers (2)

Edper
Edper

Reputation: 9322

Have you tried Url.AbsoluteUri.ToString(), like:

  Dim url As String = WebBrowser1.Url.AbsoluteUri.ToString()

Be careful with AbsoluteUri it's not AbsoluteUrl

Upvotes: 1

senthilkumar2185
senthilkumar2185

Reputation: 2566

Dim sPagePath As String = System.Web.HttpContext.Current.Request.Url.AbsolutePath

Upvotes: 1

Related Questions