static HttpHandlerFactory()
        {
            DefaultHttpHandler = new StaticFileHttpHandler();
            DirectoryHttpHandler = AspNetHandler = new AspNetHttpHandler();

            var cache = new Dictionary<string, IHttpHandler>();
            handlers = new Dictionary<string, IHttpHandler>();
            foreach (HttpHandlerElement handlerElement in ServerConfiguration.HttpHandlers)
            {
                try
                {
                    if (handlerElement.Extension == "*")
                    {
                        DefaultHttpHandler = GetOrCreateHttpHandler(handlerElement.HandlerType, cache);
                        continue;
                    }
                    if (handlerElement.Extension == "/")
                    {
                        DirectoryHttpHandler = GetOrCreateHttpHandler(handlerElement.HandlerType, cache);
                        continue;
                    }
                    if (!handlers.ContainsKey(handlerElement.Extension))
                    {
                        handlers[handlerElement.Extension] = GetOrCreateHttpHandler(handlerElement.HandlerType, cache);
                    }
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Can not create HttpHandler '{0}'.\r\n{1}", handlerElement.HandlerType, ex);
                }
            }
        }
예제 #2
0
        static HttpHandlerFactory()
        {
            DefaultHttpHandler   = new StaticFileHttpHandler();
            DirectoryHttpHandler = new AspNetHttpHandler();

            var cache = new Dictionary <string, IHttpHandler>();

            handlers = new Dictionary <string, IHttpHandler>();
            foreach (HttpHandlerElement handlerElement in ServerConfiguration.HttpHandlers)
            {
                try
                {
                    if (handlerElement.Extension == "*")
                    {
                        DefaultHttpHandler = GetOrCreateHttpHandler(handlerElement.HandlerType, cache);
                        continue;
                    }
                    if (handlerElement.Extension == "/")
                    {
                        DirectoryHttpHandler = GetOrCreateHttpHandler(handlerElement.HandlerType, cache);
                        continue;
                    }
                    if (!handlers.ContainsKey(handlerElement.Extension))
                    {
                        handlers[handlerElement.Extension] = GetOrCreateHttpHandler(handlerElement.HandlerType, cache);
                    }
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Can not create HttpHandler '{0}'.\r\n{1}", handlerElement.HandlerType, ex);
                }
            }
        }