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] ** HTTP With ASP.Net
VB.Net code
Dim WithEvents web1 As WeOnlyDo.Server.WebServer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load web1 = New WeOnlyDo.Server.WebServer web1.DocumentRoot = AppPath() + "\WebSite1" web1.DefaultPage = "Default.aspx" Try web1.Start() Catch ex As Exception MsgBox("There was an error: " & ex.Message, vbOKOnly, "Error") End Try End Sub Private Sub web1_ConnectedEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Server.WebConnectedArgs) Handles web1.ConnectedEvent Console.WriteLine("User from " + Args.User.RemoteIP + " connected") End Sub Private Sub web1_RequestDoneEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Server.WebRequestDoneArgs) Handles web1.RequestDoneEvent 'All we need to do in order to process web page is following line... Args.User.ExecuteASPX(AppPath() + "\WebSite1", "/", "/", "web.config") End Sub Public Function AppPath() As String AppPath = System.IO.Directory.GetParent(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory).ToString).ToString End Function Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed web1.Stop() End Sub C# code
private WeOnlyDo.Server.WebServer web1; private void Form1_Load(object sender, EventArgs e) { web1 = new WeOnlyDo.Server.WebServer(); web1.RequestDoneEvent += new WeOnlyDo.Server.WebServer.RequestDoneDelegate(web1_RequestDoneEvent); web1.ConnectedEvent += new WeOnlyDo.Server.WebServer.ConnectedDelegate(web1_ConnectedEvent); web1.DocumentRoot = AppPath() + "\\WebSite1"; web1.DefaultPage = "Default.aspx"; try { // Start our server. Since Port property isn't set explicitly, we will use default, port 80. web1.Start(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } void web1_ConnectedEvent(object Sender, WeOnlyDo.Server.WebConnectedArgs Args) { Console.WriteLine("User from " + Args.User.RemoteIP + " connected"); } void web1_RequestDoneEvent(object Sender, WeOnlyDo.Server.WebRequestDoneArgs Args) { // All we need to do in order to process web page is following line... Args.User.ExecuteASPX(AppPath() + "\\WebSite1", "/", "/", "web.config"); } private String AppPath() { return System.IO.Directory.GetParent(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).ToString()).ToString(); } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { web1.Stop(); } |