Базовый класс для создания веб-сервера
За основу был взят класс из блога Рика Страла (Rick Strahl) http://weblog.west-wind.com/posts/2005/Dec/04/Add-a-Web-Server-to-your-NET-20-app-with-a-few-lines-of-code
상속: IDisposable, INotifyPropertyChanged
예제 #1
0
파일: MainForm.cs 프로젝트: bazile/Training
 private static HttpServer StartHttpServer()
 {
     var httpServer = new HttpServer();
     httpServer.ReceiveWebRequest += ProcessHttpRequest;
     httpServer.Start(SERVER_URL);
     return httpServer;
 }
예제 #2
0
파일: MainForm.cs 프로젝트: bazile/Training
        private void HandleFormClosing(object sender, FormClosingEventArgs e)
        {
            if (httpServer != null)
            {
                httpServer.Stop();
                httpServer = null;
            }

            if (client != null)
            {
                client.CancelAsync();
            }
        }
예제 #3
0
파일: MainForm.cs 프로젝트: bazile/Training
        private void HandleDownloadZipButtonClick(object sender, EventArgs e)
        {
            if (httpServer == null || !httpServer.IsStarted)
            {
                httpServer = StartHttpServer();

                pictureBoxServerStatus.Image = imageListIcons.Images["server-started"];
                linkLabelServer.Text = SERVER_URL;
                linkLabelServer.Visible = true;
            }

            if (client != null) return;

            client = new WebClient();
            client.DownloadDataCompleted += DownloadDataCompleted;
            client.DownloadProgressChanged += DownloadProgressChanged;
            client.DownloadDataAsync(new Uri(SERVER_URL + "random.zip"));
        }