public HttpResponseMessage GetBanners() { try { var bannersPage = UmbracoContext.Current.ContentCache.GetAtRoot().FirstOrDefault(sibling => sibling.DocumentTypeAlias == "banners"); var service = new UmbracoBannerSettingsService(bannersPage, new UrlListReader()); var settings = service.ReadBannerSettings(); var response = Request.CreateResponse(HttpStatusCode.OK, settings); response.Headers.CacheControl = new CacheControlHeaderValue() { Public = true, MaxAge = TimeSpan.FromDays(1) }; response.Content.Headers.Expires = DateTimeOffset.Now.Add(response.Headers.CacheControl.MaxAge.Value); var corsPolicy = new CorsPolicyFromConfig().CorsPolicy; new CorsHeaders(Request.Headers, response.Headers, corsPolicy).UpdateHeaders(); return response; } catch (Exception e) { e.ToExceptionless().Submit(); return Request.CreateResponse(HttpStatusCode.InternalServerError); } }
public HttpResponseMessage GetBanners() { try { var bannersPage = UmbracoContext.Current.ContentCache.GetAtRoot().FirstOrDefault(sibling => sibling.DocumentTypeAlias == "banners"); var service = new UmbracoBannerSettingsService(bannersPage, new UrlListReader()); var settings = service.ReadBannerSettings(); var response = Request.CreateResponse(HttpStatusCode.OK, settings); response.Headers.CacheControl = new CacheControlHeaderValue() { Public = true, MaxAge = TimeSpan.FromDays(1) }; response.Content.Headers.Expires = DateTimeOffset.Now.Add(response.Headers.CacheControl.MaxAge.Value); var corsPolicy = new CorsPolicyFromConfig().CorsPolicy; new CorsHeaders(Request.Headers, response.Headers, corsPolicy).UpdateHeaders(); return(response); } catch (Exception e) { e.ToExceptionless().Submit(); return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }