示例#1
0
文件: SsiTest.cs 项目: jsakamoto/bjd5
        public static void BeforeClass()
        {
            //設定ファイルの退避と上書き
            _op = new TmpOption("WebServerTest","WebServerTest.ini");
            var kernel = new Kernel();
            var option = kernel.ListOption.Get("Web-localhost:88");
            Conf conf = new Conf(option);

            //サーバ起動
            _v4Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Tcp));
            _v4Sv.Start();

            _v6Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V6Localhost), ProtocolKind.Tcp));
            _v6Sv.Start();
        }
示例#2
0
        static void Main()
        {
            //WebServer.Security.CertificateManager.CreateCertificate("CN=localhost", new CertificateConfig
            //	{ FilePath=@"D:\cert.pfx", IsEnabled=true, Password = "******"});

            //return;

            var web = new Server(IPAddress.Any, int.Parse(ConfigurationManager.AppSettings["port"]));
            web.ResolveDnsNames = true;
            web.UseSsl = true;
            web.SetCertificatePath(@"d:\cert.pfx", "111");
            web.RequestRouter.Add(new RouteEntry("/scripts", typeof(ImagePage)));
            web.RequestRouter.Add(new RouteEntry("/", typeof(HtmlPage)));
            web.AuthenticationMethod = AuthenticationMethod.Digest;
            web.AuthenticationEvent += delegate(object sender, AuthenticationEventArgs e) { e.Accept = true;
                                                                                          	e.Password = "******";
            };
            web.Start();
            Console.WriteLine("Web server started at port: " + ConfigurationManager.AppSettings["port"]);
            Console.WriteLine("Press any key to stop");
            Console.ReadKey(true);
            web.Stop();
        }