Пример #1
0
        /// <summary>
        /// process request
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(System.Web.HttpContext context)
        {
            string requestpath = context.Request.FilePath.ToLower();

            string originpath = requestpath.Substring(0, requestpath.LastIndexOf(".")).ToLower();

            string filepath = context.Server.MapPath(originpath);

            if (originpath.EndsWith(".css"))
            {
                context.Response.ContentType = "text/css";
            }
            else if (originpath.EndsWith(".js"))
            {
                //context.Response.ContentType = "application/x-javascript";
                context.Response.ContentType = "text/javascript";
            }

            if (context.IsEncodingAccepted(GZIP))
            {
                string gz = filepath + ".gz";

                if (File.Exists(gz))
                {
                    context.SetEncoding(GZIP);

                    //context.Response.WriteFile(gz);

                    WriteFile(context, gz);

                    return;
                }
            }
            else if (context.IsEncodingAccepted(DEFLATE))
            {
                string de = filepath + ".de";

                if (File.Exists(de))
                {
                    context.SetEncoding(DEFLATE);

                    //context.Response.WriteFile(de);

                    WriteFile(context, de);

                    return;
                }
            }

            if (File.Exists(filepath))
            {
                WriteFile(context, filepath);
            }
        }