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] ** Manual response - HTTP server
VB code
Dim WithEvents wodWebServer1 As wodWebServerCom Private Sub Form_Load() Set wodWebServer1 = New wodWebServerCom wodWebServer1.Start 'start a web server End Sub 'RequestDone Event fires when wodWebServer receives request headers from the user. Private Sub wodWebServer1_RequestDone(ByVal User As WODWEBSERVERCOMLib.IWebUser) Dim resp As String resp = "<HTML><font face=Verdana size=2>Welcome visitor from " resp = resp & User.RemoteIP & ". This is <b>wodWebServer</b>, version " & wodWebServer1.Version resp = resp & "<BR>You requested resource " & User.Request.Path & User.Request.PageName resp = resp & "</font></HTML>" 'Using WebResponse object Body Property we can specify manual response 'that we want to send to client when they connect to our server. User.Response.Body = resp 'Don't forget to set status code and content type also. User.Response.Headers("Content-Type") = "text/html" User.Response.StatusCode = OK 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.Start() 'start a web server End Sub 'RequestDone Event fires when wodWebServer.NET receives request headers from the user. Private Sub wodWebServer1_RequestDoneEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Server.WebRequestDoneArgs) Handles wodWebServer1.RequestDoneEvent Dim resp As String resp = "<HTML><font face=Verdana size=2>Welcome visitor from " resp = resp & Args.User.RemoteIP & ". This is <b>wodWebServer.NET</b>, version " & wodWebServer1.Version resp = resp & "<BR>You requested resource " & Args.User.Request.Path & Args.User.Request.PageName resp = resp & "</font></HTML>" 'Using WebResponse object Body Property we can specify manual response 'that we want to send to client when they connect to our server. Args.User.Response.Body = resp 'Don't forget to set status code and content type. Args.User.Response.Headers("Content-Type").Value = "text/html" Args.User.Response.StatusCode = WeOnlyDo.Server.StatusCodes.OK End Sub C# code
private WeOnlyDo.Server.WebServer wodWebServer1; private void Form1_Load(object sender, EventArgs e) { wodWebServer1 = new WeOnlyDo.Server.WebServer(); wodWebServer1.RequestDoneEvent += new WeOnlyDo.Server.WebServer.RequestDoneDelegate(wodWebServer1_RequestDoneEvent); wodWebServer1.Start(); //start a web server } //RequestDone Event fires when wodWebServer.NET receives request headers from the user. void wodWebServer1_RequestDoneEvent(object Sender, WeOnlyDo.Server.WebRequestDoneArgs Args) { String resp = String.Empty; resp = "<HTML><font face=Verdana size=2>Welcome visitor from "; resp += Args.User.RemoteIP + ". This is <b>wodWebServer.NET</b>, version " + wodWebServer1.Version; resp += "<BR>You requested resource " + Args.User.Request.Path + Args.User.Request.PageName; resp += "</font></HTML>"; //Using WebResponse object Body Property we can specify manual response //that we want to send to client when they connect to our server. Args.User.Response.Body = resp; //Don't forget to set status code and content type. Args.User.Response.Headers["Content-Type"].Value = "text/html"; Args.User.Response.StatusCode = WeOnlyDo.Server.StatusCodes._OK; } |