VB6 - Basic Authentication example
File(s): frmBasicAuthentication.frm
The frmBasicAuthentication.frm form that is part of the demo, shows how you can handle automatic logins on a website that has a protected area using Basic Authentication.
For this, the AntView control first navigates to a freely accessible page on our server, https://basic-auth.antview.dev.
From there you can click on a link to visit the protected area. If you do so, then the browser control will popup the familiar user name and password dialog, so that you can enter the credentials needed to visit that part of the site.
There's also a checkbox at the right hand bottom of the form, to automatically login to the protected area.
The form is based on the VB6 - Web Browser example, so if you haven't seen that, then we recommend to first read that part.
The magic for the automatic login is as follows:
Private Sub EdgeWebBrowser_OnBasicAuthenticationRequested(ByVal Args As AntViewAx2.IAntViewBasicAuthenticationRequestedEventArgs)
' basic auth
If (AutoLoginCheckbox.Value = 1) Then
Args.Response.UserName = "test"
Args.Response.Password = "vapp5eGvJeXsDuTOEK62"
End If
End Sub
In other words, the moment you try to visit a protected page, the control will trigger the OnBasicAuthenticationRequested event. This event passes the Args parameter of type AntViewBasicAuthenticationRequestedEventArgs.
This parameter includes a response parameter of type AntViewBasicAuthenticationResponse that you can set to pass the username and password.
For our protected page he User Name = "test" and the password = "vapp5eGvJeXsDuTOEK62".
Note that once you have logged in that the browser control will remember those login credentials until you close the browser control. So you only need to provide the credentials once.
Introduced in AntView release 2.0.459
AntView - The MS Edge WebView2 ActiveX control Date last changed: 09/30/2024