/// <summary> /// Handles the xml format. /// </summary> /// <param name="currentPage">The current page.</param> /// <param name="httpContextBase">The HttpContext</param> public static void HandleXml(PageData currentPage, HttpContextBase httpContextBase = null) { if (currentPage.CannotBeUsedInOutput()) { return; } XmlOutputFormat xmlOutputFormat = new XmlOutputFormat(); xmlOutputFormat.HandleFormat(currentPage, httpContextBase ?? new HttpContextWrapper(HttpContext.Current)); }
/// <summary> /// Generates the response. /// </summary> /// <param name="requestedPageData"> /// The requested page data. /// </param> /// <returns> /// The requested content. /// </returns> /// <exception cref="System.Web.Http.HttpResponseException"> /// A response exception. /// </exception> private string GenerateResponse(PageData requestedPageData) { if (this.CurrentHttpContext.IsJsonAccepted()) { if (WebApiSettings.Instance.EnableJSON) { return(JsonOutputFormat.GenerateJson(requestedPageData)); } throw new HttpResponseException(HttpStatusCode.NotAcceptable); } if (this.CurrentHttpContext.IsXmlAccepted()) { if (WebApiSettings.Instance.EnableXML) { return(XmlOutputFormat.GenerateXml(requestedPageData)); } throw new HttpResponseException(HttpStatusCode.NotAcceptable); } throw new HttpResponseException(HttpStatusCode.BadRequest); }