// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Mvc.Filters; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc { /// /// Filter to prevent StatusCodePages middleware to handle responses. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class SkipStatusCodePagesAttribute : Attribute, IResourceFilter { /// public void OnResourceExecuted([NotNull] ResourceExecutedContext context) { } /// public void OnResourceExecuting([NotNull] ResourceExecutingContext context) { var statusCodeFeature = context.HttpContext.Features.Get(); if (statusCodeFeature != null) { // Turn off the StatusCodePages feature. statusCodeFeature.Enabled = false; } } } }