Moved filters to Umbraco.Web.Common project
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Umbraco.Web.BackOffice
|
||||
namespace Umbraco.Web.Common.Events
|
||||
{
|
||||
public class ActionExecutedEventArgs : EventArgs
|
||||
{
|
||||
+8
-6
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.Filters
|
||||
namespace Umbraco.Web.Common.Filters
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensures that the request is not cached by the browser
|
||||
@@ -14,9 +14,11 @@ namespace Umbraco.Web.BackOffice.Filters
|
||||
{
|
||||
base.OnResultExecuting(context);
|
||||
|
||||
if (context.HttpContext.Response.StatusCode != 200) return;
|
||||
var httpResponse = context.HttpContext.Response;
|
||||
|
||||
context.HttpContext.Response.GetTypedHeaders().CacheControl =
|
||||
if (httpResponse.StatusCode != 200) return;
|
||||
|
||||
httpResponse.GetTypedHeaders().CacheControl =
|
||||
new CacheControlHeaderValue()
|
||||
{
|
||||
NoCache = true,
|
||||
@@ -25,9 +27,9 @@ namespace Umbraco.Web.BackOffice.Filters
|
||||
NoStore = true
|
||||
};
|
||||
|
||||
context.HttpContext.Response.Headers[HeaderNames.LastModified] = DateTime.Now.ToString("R"); // Format RFC1123
|
||||
context.HttpContext.Response.Headers[HeaderNames.Pragma] = "no-cache";
|
||||
context.HttpContext.Response.Headers[HeaderNames.Expires] = new DateTime(1990, 1, 1, 0, 0, 0).ToString("R");
|
||||
httpResponse.Headers[HeaderNames.LastModified] = DateTime.Now.ToString("R"); // Format RFC1123
|
||||
httpResponse.Headers[HeaderNames.Pragma] = "no-cache";
|
||||
httpResponse.Headers[HeaderNames.Expires] = new DateTime(1990, 1, 1, 0, 0, 0).ToString("R");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Umbraco.Web.Common.Events;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.Filters
|
||||
namespace Umbraco.Web.Common.Filters
|
||||
{
|
||||
public class PreRenderViewActionFilterAttribute : ActionFilterAttribute
|
||||
{
|
||||
+8
-6
@@ -1,10 +1,10 @@
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.Filters
|
||||
namespace Umbraco.Web.Common.Filters
|
||||
{
|
||||
/// <summary>
|
||||
/// Forces the response to have a specific http status code
|
||||
@@ -22,10 +22,12 @@ namespace Umbraco.Web.BackOffice.Filters
|
||||
{
|
||||
base.OnActionExecuted(context);
|
||||
|
||||
context.HttpContext.Response.StatusCode = (int)_statusCode;
|
||||
var httpContext = context.HttpContext;
|
||||
|
||||
var disableIisCustomErrors = context.HttpContext.RequestServices.GetService<IWebRoutingSettings>().TrySkipIisCustomErrors;
|
||||
var statusCodePagesFeature = context.HttpContext.Features.Get<IStatusCodePagesFeature>();
|
||||
httpContext.Response.StatusCode = (int)_statusCode;
|
||||
|
||||
var disableIisCustomErrors = httpContext.RequestServices.GetService<IWebRoutingSettings>().TrySkipIisCustomErrors;
|
||||
var statusCodePagesFeature = httpContext.Features.Get<IStatusCodePagesFeature>();
|
||||
|
||||
if (statusCodePagesFeature != null)
|
||||
{
|
||||
Reference in New Issue
Block a user