Пример #1
0
        static void Main(string[] args)
        {
            //调用开发者批量注册的管道
            PipelineConfig.Register();
            //注册最后一个WebPipe管道
            PipelineBuilder.Bind <WebPipeline>();
            //创建管道
            _entrancePipeline = PipelineBuilder.Build();

            //基于HttpListener的web容器,实际也是依赖于http.sys来监听当前服务器的所有http请求
            HttpListener  httpListener = new HttpListener();
            List <string> prefixList   = new List <string>()
            {
                "http://127.0.0.1:20001/",
                "http://127.0.0.1:20002/",
                "http://127.0.0.1:20003/"
            };

            prefixList.ForEach(prefix =>
            {
                httpListener.Prefixes.Add(prefix);
            });

            httpListener.Start();

            Console.WriteLine("HttpListener is started...");

            while (true)
            {
                //HttpListenerContext context =  httpListener.GetContext();
                IAsyncResult        asyncResult = httpListener.BeginGetContext(null, null);
                HttpListenerContext context     = httpListener.EndGetContext(asyncResult);
                ThreadPool.QueueUserWorkItem(ProcessRequest, context);
            }
        }
Пример #2
0
 /// <summary>
 /// 注册自定义管道
 /// </summary>
 public static void Register()
 {
     PipelineBuilder.Bind <AuthenticationPipeline>();
     PipelineBuilder.Bind <ModelValidPipeline>();
 }