/// <summary> /// Enables a WebAssetHttpHandler object to process of requests. /// </summary> /// <param name="context">The context.</param> public override void ProcessRequest(HttpContextBase context) { string id = context.Request.QueryString[IdParameterName]; if (!string.IsNullOrEmpty(id)) { WebAssetGroup group = SharedWebAssets.FindScriptGroup(id) ?? SharedWebAssets.FindStyleSheetGroup(id) ?? new WebAssetGroupSerializer().Deserialize(id); if (group != null) { HttpResponseBase response = context.Response; // Set the content type response.ContentType = group.ContentType; string content = reader.Read(group); if (!string.IsNullOrEmpty(content)) { // Compress if (group.Compress && !context.IsMono()) { httpResponseCompressor.Compress(context); } // Write using (StreamWriter sw = new StreamWriter((response.OutputStream))) { sw.Write(content); } // Cache if (!context.IsDebuggingEnabled) { httpResponseCacher.Cache(context, TimeSpan.FromDays(group.CacheDurationInDays)); } } } } }
/// <summary> /// Enables a WebAssetHttpHandler object to process of requests. /// </summary> /// <param name="context">The context.</param> public override void ProcessRequest(HttpContextBase context) { string id = context.Request.QueryString[IdParameterName]; if (!string.IsNullOrEmpty(id)) { WebAsset asset = assetRegistry.Retrieve(id); if (asset != null) { HttpResponseBase response = context.Response; // Set the content type response.ContentType = asset.ContentType; string content = asset.Content; if (!string.IsNullOrEmpty(content)) { // Compress if (asset.Compress && !context.IsMono()) { httpResponseCompressor.Compress(context); } // Write using (StreamWriter sw = new StreamWriter((response.OutputStream))) { sw.Write(content); } // Cache if (!context.IsDebuggingEnabled) { httpResponseCacher.Cache(context, TimeSpan.FromDays(asset.CacheDurationInDays)); } } } } }