/// <summary> /// Processes a response content /// </summary> /// <param name="context">HTTP context</param> /// <param name="controllerName">Controller name</param> /// <param name="actionName">Action name</param> /// <exception cref="InvalidContentTypeException">Content type is not equals to 'text/html'.</exception> protected override void ProcessContent(HttpContextBase context, string controllerName, string actionName) { HttpRequestBase request = context.Request; HttpResponseBase response = context.Response; Encoding encoding = response.ContentEncoding; string contentType = response.ContentType; if (contentType != ContentType.Html) { throw new InvalidContentTypeException( string.Format(Strings.ErrorMessage_InvalidContentType, "MinifyHtmlAttribute", controllerName, actionName)); } if (response.StatusCode == 200) { var htmlMinifier = WebMarkupMinContext.Current.Markup.CreateHtmlMinifierInstance(); response.Filter = new HtmlMinificationFilterStream(response.Filter, htmlMinifier, request.RawUrl, encoding); if (WebMarkupMinContext.Current.IsCopyrightHttpHeadersEnabled()) { CopyrightHelper.AddHtmlMinificationPoweredByHttpHeader(response); } } }
/// <summary> /// Processes a response content /// </summary> /// <param name="context">HTTP response</param> protected override void ProcessContent(HttpContext context) { HttpRequest request = context.Request; HttpResponse response = context.Response; Encoding encoding = response.ContentEncoding; string contentType = response.ContentType; if (request.HttpMethod == "GET" && response.StatusCode == 200 && contentType == ContentType.Html && context.CurrentHandler != null) { var htmlMinifier = WebMarkupMinContext.Current.Markup.CreateHtmlMinifierInstance(); response.Filter = new HtmlMinificationFilterStream(response.Filter, htmlMinifier, request.RawUrl, encoding); if (WebMarkupMinContext.Current.IsCopyrightHttpHeadersEnabled()) { CopyrightHelper.AddHtmlMinificationPoweredByHttpHeader(response); } } }