Ejemplo n.º 1
0
        public void WebHost_Test()
        {
            string  physicalPath = Path.GetTempPath() + Helper.NewGuid().ToString("D");
            WebHost host         = null;

            Directory.CreateDirectory(physicalPath);

            try
            {
                Helper.AppendToFile(physicalPath + Helper.PathSepString + "test.htm", "<html><body>Hello World!</body></html>");
                host = new WebHost(new string[] { "http://localhost:9000/test" }, physicalPath, true);

                Thread.Sleep(10000);
            }
            finally
            {
                if (host != null)
                {
                    host.Close();
                }

                Helper.DeleteFile(physicalPath + Helper.PathSepString + "*.*", true);
                Helper.DeleteFile(physicalPath);
            }
        }
Ejemplo n.º 2
0
 internal static void OnStop()
 {
     if (_webHost != null)
     {
         _webHost.Close();
     }
     //
     if ((_serviceHost != null) && (_serviceHost.State != CommunicationState.Closed))
     {
         _serviceHost.Close();
     }
 }