Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            var result = _pipeline.ProcessRequest(request.PhysicalPath);

            if (result == null)
            {
                response.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }
            else
            {
                // TODO: This may be needed for kernel caching.  Is it worth it?
                //response.Cache.SetOmitVaryStar(true);

                response.Cache.SetCacheability(HttpCacheability.Public);
                if (result.MaxAgeSeconds.HasValue)
                {
                    response.Cache.SetMaxAge(TimeSpan.FromSeconds(result.MaxAgeSeconds.Value));
                }
                if (result.CacheInvalidationFileList.Any())
                {
                    response.AddFileDependencies(result.CacheInvalidationFileList.ToArray());
                }
                response.Cache.SetLastModifiedFromFileDependencies();
                response.Cache.SetETagFromFileDependencies();
                response.ContentEncoding = Encoding.UTF8;
                response.ContentType     = result.MimeType;
                response.Write(result.Content);
            }
        }
        public void ProcessRequest(HttpContextBase context)
        {
            var request  = context.Request;
            var response = context.Response;

            try
            {
                var result = pipeline.ProcessRequest(request.PhysicalPath);
                if (result == null)
                {
                    response.StatusCode = (int)HttpStatusCode.NotFound;
                    return;
                }
                response.ContentEncoding = Encoding.UTF8;
                response.ContentType     = result.MimeType;
                response.Write(result.Content);
            }
            catch (Exception ex)
            {
                response.StatusCode = 500;
                response.Write("/* Error in compiling: " + ex + " */");
            }
        }
Esempio n. 3
0
        public void ProcessRequest(HttpContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            var result = _pipeline.ProcessRequest(request.PhysicalPath);

            if (result == null)
            {
                response.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

            if (_cacheProfile.Enabled)
            {
                SetCachePolicy(response, _cacheProfile.Location);
                response.Cache.SetMaxAge(TimeSpan.FromSeconds(_cacheProfile.Duration));
                response.Cache.SetExpires(DateTime.UtcNow.AddSeconds(_cacheProfile.Duration));

                if (_cacheProfile.NoStore)
                {
                    response.Cache.SetNoStore();
                }

                // No SQL dependency, VaryByControl, or VaryByCustom support for now
                SetVaryBy(_cacheProfile.VaryByContentEncoding, encoding => response.Cache.VaryByContentEncodings[encoding] = true);

                if (_cacheProfile.VaryByHeader == "*")
                {
                    response.Cache.VaryByHeaders.VaryByUnspecifiedParameters();
                }
                else
                {
                    SetVaryBy(_cacheProfile.VaryByHeader, header => response.Cache.VaryByHeaders[header] = true);
                }

                if (_cacheProfile.VaryByParam != "*")
                {
                    response.Cache.SetOmitVaryStar(true);
                    if (string.IsNullOrWhiteSpace(_cacheProfile.VaryByParam) ||
                        _cacheProfile.VaryByParam == "none")
                    {
                        response.Cache.VaryByParams.IgnoreParams = true;
                    }
                    else
                    {
                        SetVaryBy(_cacheProfile.VaryByParam, param => response.Cache.VaryByParams[param] = true);
                    }
                }

                if (result.CacheInvalidationFileList.Any())
                {
                    response.AddFileDependencies(result.CacheInvalidationFileList.ToArray());
                    response.Cache.SetLastModifiedFromFileDependencies();
                    response.Cache.SetETagFromFileDependencies();
                }
            }
            else
            {
                response.Cache.SetCacheability(HttpCacheability.NoCache);
            }

            response.ContentEncoding = Encoding.UTF8;
            response.ContentType     = result.MimeType;
            response.Write(result.Content);
        }