All wodCrypt (12) wodSSH (10) wodSFTP (23) wodSSHServer (1) wodSSHTunnel (11) wodSSHpackage wodSFTPdll wodSSH.NET (10) wodSFTP.NET (24) wodFtpDLX.NET (22) wodWebServer.NET (10) wodAppUpdate (13) wodHttpDLX (8) wodFtpDLX (22) wodTelnetDLX wodFTPServer (3) wodWebServer (10) wodVPN wodXMPP (13) | All ** [Visual Basic] ** [C#] ** [VB.NET] ** Basic authentication in HTTP server
VB code
Dim WithEvents wodWebServer1 As wodWebServerCom Private Sub Form_Load() Set wodWebServer1 = New wodWebServerCom wodWebServer1.DocumentRoot = App.Path wodWebServer1.Authentication = AuthRequired 'Determines if authentication is required wodWebServer1.AuthenticationType = AuthBasic 'Determines type of authentication wodWebServer1.Start 'Start a web server End Sub 'UserAuthenticate Event fires when user wants to authenticate. Private Sub wodWebServer1_UserAuthenticate(ByVal User As WODWEBSERVERCOMLib.IWebUser, ByVal AuthType As WODWEBSERVERCOMLib.WebAuthenticationTypes, Action As WODWEBSERVERCOMLib.WebActions) If AuthType = AuthBasic Then 'In this example we will allow only user with login joe and password test to connect to server. All other attempts will be rejected. If User.Login = "joe" And User.Password = "test" Then Action = Allow Else Action = Deny End If Else Action = Deny End If End Sub VB.NET code
Dim WithEvents wodWebServer1 As WeOnlyDo.Server.WebServer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load wodWebServer1 = New WeOnlyDo.Server.WebServer wodWebServer1.DefaultPage = "index.html" 'Specify default page file wodWebServer1.DocumentRoot = "C:\Web" wodWebServer1.Authentication = WeOnlyDo.Server.WebAuthentications.Required 'Determines if authentication is required wodWebServer1.AuthenticationType = WeOnlyDo.Server.WebAuthenticationTypes.Basic 'Determines type of authentication wodWebServer1.Start() 'Start a web server End Sub 'UserAuthenticate Event fires when user wants to authenticate. Private Sub wodWebServer1_AuthenticateEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Server.WebAuthenticateArgs) Handles wodWebServer1.AuthenticateEvent If Args.AuthenticationType = WeOnlyDo.Server.WebAuthenticationTypes.Basic Then 'In this example we will allow only user with login joe and password test to connect to server. All other attempts will be rejected. If Args.Login = "joe" And Args.Password = "test" Then Args.Action = WeOnlyDo.Server.WebActions.Allow Else Args.Action = WeOnlyDo.Server.WebActions.Deny End If Else Args.Action = WeOnlyDo.Server.WebActions.Deny End If End Sub C# code
WeOnlyDo.Server.WebServer wodWebServer1; private void Form1_Load(System.Object sender, System.EventArgs e) { wodWebServer1 = new WeOnlyDo.Server.WebServer(); wodWebServer1.AuthenticateEvent += new WeOnlyDo.Server.WebServer.AuthenticateDelegate(wodWebServer1_AuthenticateEvent); wodWebServer1.DefaultPage = "index.html"; //Specify default page file wodWebServer1.DocumentRoot = "C:\\Web"; wodWebServer1.Authentication = WeOnlyDo.Server.WebAuthentications.Required; //Determines if authentication is required wodWebServer1.AuthenticationType = WeOnlyDo.Server.WebAuthenticationTypes.Basic; //Determines type of authentication wodWebServer1.Start(); //Start a web server } //UserAuthenticate Event fires when user wants to authenticate. void wodWebServer1_AuthenticateEvent(object Sender, WeOnlyDo.Server.WebAuthenticateArgs Args) { if (Args.AuthenticationType == WeOnlyDo.Server.WebAuthenticationTypes.Basic) { //In this example we will allow only user with login joe and password test to connect to server. All other attempts will be rejected. if (Args.Login == "joe" && Args.Password == "test") { Args.Action = WeOnlyDo.Server.WebActions.Allow; } else { Args.Action = WeOnlyDo.Server.WebActions.Deny; } } else { Args.Action = WeOnlyDo.Server.WebActions.Deny; } } |