/// <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="WebMarkupMin.Web.InvalidContentTypeException">Content type is not XML-based.</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 (!ContentTypeHelper.IsXmlBasedContentType(contentType) && contentType != ContentType.Xhtml) { throw new InvalidContentTypeException( string.Format(Strings.ErrorMessage_InvalidContentType, "MinifyXmlAttribute", controllerName, actionName)); } if (response.StatusCode == 200) { var xmlMinifier = WebMarkupMinContext.Current.Markup.CreateXmlMinifierInstance(); response.Filter = new XmlMinificationFilterStream(response.Filter, xmlMinifier, request.RawUrl, encoding); if (WebMarkupMinContext.Current.IsCopyrightHttpHeadersEnabled()) { CopyrightHelper.AddXmlMinificationPoweredByHttpHeader(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 && ContentTypeHelper.IsXmlBasedContentType(contentType) && context.CurrentHandler != null) { var xmlMinifier = WebMarkupMinContext.Current.Markup.CreateXmlMinifierInstance(); response.Filter = new XmlMinificationFilterStream(response.Filter, xmlMinifier, request.RawUrl, encoding); if (WebMarkupMinContext.Current.IsCopyrightHttpHeadersEnabled()) { CopyrightHelper.AddXmlMinificationPoweredByHttpHeader(response); } } }