AssetPackager.ScriptsHandler.ProcessRequest C# (CSharp) Method

ProcessRequest() public method

Enables processing of HTTP Web requests by a custom HttpHandler that implements the IHttpHandler interface.
public ProcessRequest ( HttpContext context ) : void
context System.Web.HttpContext A object that provides references to /// the intrinsic server objects (for example, Request, Response, Session, and Server) /// used to service HTTP requests.
return void
		public void ProcessRequest(HttpContext context)
		{
			Query query = QueryHelper.ParseQuery();

			string cacheKey = String.Format(CultureInfo.InvariantCulture,
			                                Settings.ScriptsCacheKeyFormat,
			                                Settings.AppVersion,
											query.AssetList + "=" + AssetsHelper.SerializeAssets(query.Assets));
			byte[] encodedBytes = (byte[]) CacheHelper.GetData(cacheKey, null,
			                                                   DateTime.Now.AddHours(Settings.CacheDuration),
			                                                   CacheItemPriority.NotRemovable,
			                                                   delegate { return CombineScripts(query.Assets); });

			context.Response.ContentType = AssetListTypeHelper.GetMimeType(query.AssetList.ListType);
			context.Response.ContentEncoding = context.Request.ContentEncoding;
			context.Response.Cache.SetMaxAge(TimeSpan.FromHours(Settings.CacheDuration));
			context.Response.Cache.SetExpires(DateTime.Now.AddHours(Settings.CacheDuration));
			context.Response.Cache.SetCacheability(HttpCacheability.Private);
			context.Response.AppendHeader("Content-Length", encodedBytes.Length.ToString(CultureInfo.InvariantCulture));

			context.Response.OutputStream.Write(encodedBytes, 0, encodedBytes.Length);
			context.Response.Flush();
		}