/// <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));
}
}
}
}
}