|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Hi,
I want to know how EO.WebBrowser can remember username/password to auto login like Google Chrome. Many web browsers store credentials somewhere to allow to jump right the page without login in. I would like to see how we can do it with EO.WebBrowser.
Thank you.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
You will need to do that part yourself and then handle the WebView's NeedCredentials to supply them to the browser engine. Google Chrome browser does do that but that is not a part of the core browser engine so it does not exist in EO.WebBrowser.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Thank you for your reply. However, I don't see the WebView's NeedCredentials to get fired, even with login and logout, reopen the EO.WebBrowser instance to login again but this event is never got fired. Could you please give me an example to use this NeedCredentials event.
I am using the current latest version 16.1.46.
Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
NeedCredentials is only fired when there is a "401 Unauthorized" response. If your website automatically redirects to a login page (thus still responds 200), the WebView has no way of knowing that it is actually a login page. In that case NeedsCredentials will not be fired. In order to automatically log into those pages, there are two options:
1. Automatically detects form fields and "guess" whether it's a login page, and uses auto fill mechanism to automatically fills in the form fields, then submit the page. EO.WebView only provides interface for you to read/write form fields and you will need to implement everything else;
2. If the server uses cookies to store authentication ticket, then you can capture the cookies and then attach it to the WebView's BeforeRequestLoad event later. That will automatically authenticate you with the server;
Hope this helps. Please feel free to let us know if you still have any questions.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Your suggestion works. I am working with the 2nd option. However, how can I get the CookieCollection inside the WebView's BeforeRequestLoad event?
Thank you.
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Here is the code to help to clear my question:
Code: C#
private void webView_BeforeRequestLoad(object sender, BeforeRequestLoadEventArgs e)
{
var cookie = new Cookie("COOKIENAME");
// Where to get the CookieCollection of this webView to retrieve the cookie value from a given cookie name?
cookie.Value = "xxx";
e.Request.Cookies.Add(cookie);
}
Thank you.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
You won't be able to get the cookies from BeforeRequestLoad. You can only get the cookies from AfterReceiveHeaders event.
Thanks!
|
|