コード例 #1
0
ファイル: MergeHttpHandler.cs プロジェクト: ddd-cqrs-es/must
        /// <summary>
        /// Process the HTTP request.
        /// </summary>
        /// <param name="context">An HttpContext object that provides references to the intrinsic server objects
        /// used to service HTTP request</param>
        public void ProcessRequest(HttpContext context)
        {
            string content_type;
            string content_group_name;
            string requested_file_path;
            string requested_file_extentsion;
            int    position;

            context_     = context;
            content_type = "text/html";

            try {
                settings_ = NohrosConfiguration.DefaultConfiguration;
            } catch (System.Configuration.ConfigurationErrorsException exception) {
                FileLogger.ForCurrentProcess.Logger.Error("[GetMergedContent   Nohros.Net.MergeHttpHandler]", exception);
                // the configuration file was not defined. we cant do nothing.
                context.Response.StatusCode = kResourceNotFoundCode;
                context.Response.End();
                return;
            }

            requested_file_path = context.Request.FilePath;

            // attempt to get the content type from the requested file estension
            requested_file_extentsion = Path.GetExtension(requested_file_path);
            switch (requested_file_extentsion)
            {
            case ".js":
                content_type = "application/x-javascript";
                break;

            case ".css":
                content_type = "text/css";
                break;

            default:
                context.Response.StatusCode = kResourceNotFoundCode;
                context.Response.End();
                break;
            }

            // attempt to get the content group name from the virtual path.
            position = requested_file_path.IndexOf(kVirtualFilePathSuffix);
            if (position == -1)
            {
                // the handler is configured incorrectly.
                FileLogger.ForCurrentProcess.Logger.Error("[ProcessRequest   Nohros.Net.MergeHttpHandler] The handler is configured incorrectly. Check handlers session of the the web.config file");
                context_.Response.StatusCode = kResourceNotFoundCode;
                context_.Response.End();
                return;
            }

            content_group_name = Path.GetFileNameWithoutExtension(
                requested_file_path.Substring(0, position));

            GetMergedContent(content_group_name, content_type);
        }
コード例 #2
0
        /// <summary>
        /// Process the HTTP request.
        /// </summary>
        /// <param name="context">An HttpContext object that provides references to the intrinsic server objects
        /// used to service HTTP request</param>
        public void ProcessRequest(HttpContext context)
        {
            string content_type;
            string content_group_name;
            string requested_file_path;
            string requested_file_extentsion;
            int position;

            context_ = context;
            content_type = "text/html";

            try {
                settings_ = NohrosConfiguration.DefaultConfiguration;
            } catch (System.Configuration.ConfigurationErrorsException exception) {
                FileLogger.ForCurrentProcess.Logger.Error("[GetMergedContent   Nohros.Net.MergeHttpHandler]", exception);
                // the configuration file was not defined. we cant do nothing.
                context.Response.StatusCode = kResourceNotFoundCode;
                context.Response.End();
                return;
            }

            requested_file_path = context.Request.FilePath;

            // attempt to get the content type from the requested file estension
            requested_file_extentsion = Path.GetExtension(requested_file_path);
            switch (requested_file_extentsion) {
                case ".js":
                    content_type = "application/x-javascript";
                    break;

                case ".css":
                    content_type = "text/css";
                    break;

                default:
                    context.Response.StatusCode = kResourceNotFoundCode;
                    context.Response.End();
                    break;
            }

            // attempt to get the content group name from the virtual path.
            position = requested_file_path.IndexOf(kVirtualFilePathSuffix);
            if(position == -1) {
                // the handler is configured incorrectly.
                FileLogger.ForCurrentProcess.Logger.Error("[ProcessRequest   Nohros.Net.MergeHttpHandler] The handler is configured incorrectly. Check handlers session of the the web.config file");
                context_.Response.StatusCode = kResourceNotFoundCode;
                context_.Response.End();
                return;
            }

            content_group_name = Path.GetFileNameWithoutExtension(
                requested_file_path.Substring(0, position));

            GetMergedContent(content_group_name, content_type);
        }