V
V
Victor Nasonov2017-04-30 16:04:36
WPF
Victor Nasonov, 2017-04-30 16:04:36

Why does webbrowser lose link after #?

I wrote a wpf program that logs in to vk through a webbrowser.
In windows 7, after the redirect, the part with the access token that comes after # is lost.
for example, it should be https://oauth.vk.com/blank.html#access_token=84ece...
but it turns out https://oauth.vk.com/blank.html
In windows 10 everything works fine (the part after # is not lost ).
What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tom Nolane, 2017-04-30
@kvonosan

here is my code that works (ps VK swears at low IE versions, and at one time my application worked on my computer, but when I put it on my sister's computer (we have VIN7, but I have updated IE (11), she has no (8), her VK refused to launch - they say the old browser ... that's why I use awesomium instead of a standard browser):

public Form1()
        {
            InitializeComponent();
             
            webbrowser.BringToFront(); 
            webbrowser.Visible = true;
            string url = "https://oauth.vk.com/authorize?client_id=" + VK_main.ID_APP + "&display=page&redirect_uri=https://oauth.vk.com/blank.html&scope=" + VK_main.SCOPE + "&response_type=token&v=" + VK_main.VERSION; 
            webbrowser.LoadingFrameComplete += Webbrowser_LoadingFrameComplete; //жду окончания загрузки
            webbrowser.Source = new Uri(url);
        }

        private void Webbrowser_LoadingFrameComplete(object sender, FrameEventArgs e)
        {
            if (!e.IsMainFrame) return;

            if(e.Url.ToString().Contains("https://oauth.vk.com/blank.html#access_token="))
            { 
                int start = e.Url.Fragment.IndexOf("=");
                int end = e.Url.Fragment.IndexOf("&");
                VK_main.TOKEN = e.Url.Fragment.Substring(start+1, end-start-1); // записываю в "глобальную переменную токен
                webbrowser.LoadingFrameComplete -= Webbrowser_LoadingFrameComplete;
                webbrowser.Visible = false;
            }
        }

ps the problem may be in IE version (default webbrowser - uses IE core)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question