Exemple #1
0
        /// <summary>
        /// Determines the appropriate source for the incomming request
        /// </summary>
        /// <param name="context"></param>
        /// <param name="isDebug"></param>
        /// <returns>CompiledBuildResult</returns>
        protected virtual IOptimizedResult GetResourceInfo(HttpContext context, bool isDebug)
        {
            string           virtualPath = context.Request.AppRelativeCurrentExecutionFilePath;
            IOptimizedResult info        = ResourceHandler.Create <IOptimizedResult>(virtualPath);

            if (info == null)
            {
                throw new HttpException(404, "Resource not found: " + virtualPath);
            }

            // check if client has cached copy
            ETag etag = new HashETag(info.Hash);

            if (etag.HandleETag(context, HttpCacheability.ServerAndPrivate, isDebug))
            {
                return(null);
            }

            return(info);
        }
Exemple #2
0
        public virtual IHttpHandler GetHandler(HttpContext context, string verb, string url, string path)
        {
            if ("GET".Equals(verb, StringComparison.OrdinalIgnoreCase) &&
                String.IsNullOrEmpty(context.Request.PathInfo))
            {
                // output service javascript proxy
                return(new ResourceHandler(context));
            }

            // handle service requests
            string           appUrl      = context.Request.AppRelativeCurrentExecutionFilePath;
            IJsonServiceInfo serviceInfo = ResourceHandler.Create <IJsonServiceInfo>(appUrl);

            if (!context.IsDebuggingEnabled && !Settings.DisableStreamCompression)
            {
                ResourceHandler.EnableStreamCompression(context);
            }

            return(new JsonServiceHandler(serviceInfo, url));
        }