Merge remote-tracking branch 'origin/release' into dev

This commit is contained in:
Doug Bunting 2016-04-13 16:04:14 -07:00
commit ee2cfa1963
55 changed files with 472 additions and 56 deletions

View File

@ -5,6 +5,9 @@ using Microsoft.AspNetCore.Mvc.Filters;
namespace Microsoft.AspNetCore.Mvc.Authorization
{
/// <summary>
/// A filter that allows anonymous requests, disabling some <see cref="IAuthorizationFilter"/>s.
/// </summary>
public interface IAllowAnonymousFilter : IFilterMetadata
{
}

View File

@ -7,11 +7,20 @@ using System.Runtime.ExceptionServices;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A context for action filters, specifically <see cref="IActionFilter.OnActionExecuted"/> calls.
/// </summary>
public class ActionExecutedContext : FilterContext
{
private Exception _exception;
private ExceptionDispatchInfo _exceptionDispatchInfo;
/// <summary>
/// Instantiates a new <see cref="ActionExecutingContext"/> instance.
/// </summary>
/// <param name="actionContext">The <see cref="ActionContext"/>.</param>
/// <param name="filters">All applicable <see cref="IFilterMetadata"/> implementations.</param>
/// <param name="controller">The controller instance containing the action.</param>
public ActionExecutedContext(
ActionContext actionContext,
IList<IFilterMetadata> filters,
@ -21,10 +30,20 @@ namespace Microsoft.AspNetCore.Mvc.Filters
Controller = controller;
}
/// <summary>
/// Gets or sets an indication that an action filter short-circuited the action and the action filter pipeline.
/// </summary>
public virtual bool Canceled { get; set; }
/// <summary>
/// Gets the controller instance containing the action.
/// </summary>
public virtual object Controller { get; }
/// <summary>
/// Gets or sets the <see cref="System.Exception"/> caught while executing the action or action filters, if
/// any.
/// </summary>
public virtual Exception Exception
{
get
@ -46,6 +65,10 @@ namespace Microsoft.AspNetCore.Mvc.Filters
}
}
/// <summary>
/// Gets or sets the <see cref="System.Runtime.ExceptionServices.ExceptionDispatchInfo"/> for the
/// <see cref="Exception"/>, if an <see cref="System.Exception"/> was caught and this information captured.
/// </summary>
public virtual ExceptionDispatchInfo ExceptionDispatchInfo
{
get
@ -60,8 +83,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters
}
}
/// <summary>
/// Gets or sets an indication that the <see cref="Exception"/> has been handled.
/// </summary>
public virtual bool ExceptionHandled { get; set; }
/// <summary>
/// Gets or sets the <see cref="IActionResult"/>.
/// </summary>
public virtual IActionResult Result { get; set; }
}
}

View File

@ -6,8 +6,21 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A context for action filters, specifically <see cref="IActionFilter.OnActionExecuted"/> and
/// <see cref="IAsyncActionFilter.OnActionExecutionAsync"/> calls.
/// </summary>
public class ActionExecutingContext : FilterContext
{
/// <summary>
/// Instantiates a new <see cref="ActionExecutingContext"/> instance.
/// </summary>
/// <param name="actionContext">The <see cref="ActionContext"/>.</param>
/// <param name="filters">All applicable <see cref="IFilterMetadata"/> implementations.</param>
/// <param name="actionArguments">
/// The arguments to pass when invoking the action. Keys are parameter names.
/// </param>
/// <param name="controller">The controller instance containing the action.</param>
public ActionExecutingContext(
ActionContext actionContext,
IList<IFilterMetadata> filters,
@ -24,10 +37,20 @@ namespace Microsoft.AspNetCore.Mvc.Filters
Controller = controller;
}
/// <summary>
/// Gets or sets the <see cref="IActionResult"/> to execute. Setting <see cref="Result"/> to a non-<c>null</c>
/// value inside an action filter will short-circuit the action and any remaining action filters.
/// </summary>
public virtual IActionResult Result { get; set; }
/// <summary>
/// Gets the arguments to pass when invoking the action. Keys are parameter names.
/// </summary>
public virtual IDictionary<string, object> ActionArguments { get; }
/// <summary>
/// Gets the controller instance containing the action.
/// </summary>
public virtual object Controller { get; }
}
}

View File

@ -5,5 +5,12 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A delegate that asynchronously returns an <see cref="ActionExecutedContext"/> indicating the action or the next
/// action filter has executed.
/// </summary>
/// <returns>
/// A <see cref="Task"/> that on completion returns an <see cref="ActionExecutedContext"/>.
/// </returns>
public delegate Task<ActionExecutedContext> ActionExecutionDelegate();
}

View File

@ -1,13 +1,21 @@
// 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 System.Collections.Generic;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A context for authorization filters i.e. <see cref="IAuthorizationFilter"/> and
/// <see cref="IAsyncAuthorizationFilter"/> implementations.
/// </summary>
public class AuthorizationFilterContext : FilterContext
{
/// <summary>
/// Instantiates a new <see cref="AuthorizationFilterContext"/> instance.
/// </summary>
/// <param name="actionContext">The <see cref="ActionContext"/>.</param>
/// <param name="filters">All applicable <see cref="IFilterMetadata"/> implementations.</param>
public AuthorizationFilterContext(
ActionContext actionContext,
IList<IFilterMetadata> filters)
@ -15,6 +23,10 @@ namespace Microsoft.AspNetCore.Mvc.Filters
{
}
/// <summary>
/// Gets or sets the result of the request. Setting <see cref="Result"/> to a non-<c>null</c> value inside
/// an authorization filter will short-circuit the remainder of the filter pipeline.
/// </summary>
public virtual IActionResult Result { get; set; }
}
}

View File

@ -7,16 +7,28 @@ using System.Runtime.ExceptionServices;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A context for exception filters i.e. <see cref="IExceptionFilter"/> and
/// <see cref="IAsyncExceptionFilter"/> implementations.
/// </summary>
public class ExceptionContext : FilterContext
{
private Exception _exception;
private ExceptionDispatchInfo _exceptionDispatchInfo;
/// <summary>
/// Instantiates a new <see cref="ExceptionContext"/> instance.
/// </summary>
/// <param name="actionContext">The <see cref="ActionContext"/>.</param>
/// <param name="filters">All applicable <see cref="IFilterMetadata"/> implementations.</param>
public ExceptionContext(ActionContext actionContext, IList<IFilterMetadata> filters)
: base(actionContext, filters)
{
}
/// <summary>
/// Gets or sets the <see cref="System.Exception"/> caught while executing the action.
/// </summary>
public virtual Exception Exception
{
get
@ -38,6 +50,10 @@ namespace Microsoft.AspNetCore.Mvc.Filters
}
}
/// <summary>
/// Gets or sets the <see cref="System.Runtime.ExceptionServices.ExceptionDispatchInfo"/> for the
/// <see cref="Exception"/>, if this information was captured.
/// </summary>
public virtual ExceptionDispatchInfo ExceptionDispatchInfo
{
get
@ -52,6 +68,9 @@ namespace Microsoft.AspNetCore.Mvc.Filters
}
}
/// <summary>
/// Gets or sets the <see cref="IActionResult"/>.
/// </summary>
public virtual IActionResult Result { get; set; }
}
}

View File

@ -6,8 +6,16 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// An abstract context for filters.
/// </summary>
public abstract class FilterContext : ActionContext
{
/// <summary>
/// Instantiates a new <see cref="FilterContext"/> instance.
/// </summary>
/// <param name="actionContext">The <see cref="ActionContext"/>.</param>
/// <param name="filters">All applicable <see cref="IFilterMetadata"/> implementations.</param>
public FilterContext(
ActionContext actionContext,
IList<IFilterMetadata> filters)
@ -21,6 +29,9 @@ namespace Microsoft.AspNetCore.Mvc.Filters
Filters = filters;
}
/// <summary>
/// Gets all applicable <see cref="IFilterMetadata"/> implementations.
/// </summary>
public virtual IList<IFilterMetadata> Filters { get; }
}
}

View File

@ -6,8 +6,18 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A context for filter providers i.e. <see cref="IFilterProvider"/> implementations.
/// </summary>
public class FilterProviderContext
{
/// <summary>
/// Instantiates a new <see cref="FilterProviderContext"/> instance.
/// </summary>
/// <param name="actionContext">The <see cref="ActionContext"/>.</param>
/// <param name="items">
/// The <see cref="FilterItem"/>s, initially created from <see cref="FilterDescriptor"/>s or a cache entry.
/// </param>
public FilterProviderContext(ActionContext actionContext, IList<FilterItem> items)
{
if (actionContext == null)
@ -24,10 +34,16 @@ namespace Microsoft.AspNetCore.Mvc.Filters
Results = items;
}
// Input
/// <summary>
/// Gets or sets the <see cref="ActionContext"/>.
/// </summary>
public ActionContext ActionContext { get; set; }
// Results
/// <summary>
/// Gets or sets the <see cref="FilterItem"/>s, initially created from <see cref="FilterDescriptor"/>s or a
/// cache entry. <see cref="IFilterProvider"/>s should set <see cref="FilterItem.Filter"/> on existing items or
/// add new <see cref="FilterItem"/>s to make executable filters available.
/// </summary>
public IList<FilterItem> Results { get; set; }
}
}

View File

@ -3,10 +3,21 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that surrounds execution of the action.
/// </summary>
public interface IActionFilter : IFilterMetadata
{
/// <summary>
/// Called before the action executes, after model binding is complete.
/// </summary>
/// <param name="context">The <see cref="ActionExecutingContext"/>.</param>
void OnActionExecuting(ActionExecutingContext context);
/// <summary>
/// Called after the action executes, before the action result.
/// </summary>
/// <param name="context">The <see cref="ActionExecutedContext"/>.</param>
void OnActionExecuted(ActionExecutedContext context);
}
}

View File

@ -5,8 +5,19 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that asynchronously surrounds execution of the action, after model binding is complete.
/// </summary>
public interface IAsyncActionFilter : IFilterMetadata
{
/// <summary>
/// Called asynchronously before the action, after model binding is complete.
/// </summary>
/// <param name="context">The <see cref="ActionExecutingContext"/>.</param>
/// <param name="next">
/// The <see cref="ActionExecutionDelegate"/>. Invoked to execute the next action filter or the action itself.
/// </param>
/// <returns>A <see cref="Task"/> that on completion indicates the filter has executed.</returns>
Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next);
}
}

View File

@ -5,8 +5,18 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that asynchronously confirms request authorization.
/// </summary>
public interface IAsyncAuthorizationFilter : IFilterMetadata
{
/// <summary>
/// Called early in the filter pipeline to confirm request is authorized.
/// </summary>
/// <param name="context">The <see cref="AuthorizationFilterContext"/>.</param>
/// <returns>
/// A <see cref="Task"/> that on completion indicates the filter has executed.
/// </returns>
Task OnAuthorizationAsync(AuthorizationFilterContext context);
}
}

View File

@ -5,8 +5,16 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that runs asynchronously after an action has thrown an <see cref="System.Exception"/>.
/// </summary>
public interface IAsyncExceptionFilter : IFilterMetadata
{
/// <summary>
/// Called after an action has thrown an <see cref="System.Exception"/>.
/// </summary>
/// <param name="context">The <see cref="ExceptionContext"/>.</param>
/// <returns>A <see cref="Task"/> that on completion indicates the filter has executed.</returns>
Task OnExceptionAsync(ExceptionContext context);
}
}

View File

@ -6,18 +6,18 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter which surrounds execution of model binding, the action (and filters) and the action result
/// (and filters).
/// A filter that asynchronously surrounds execution of model binding, the action (and filters) and the action
/// result (and filters).
/// </summary>
public interface IAsyncResourceFilter : IFilterMetadata
{
/// <summary>
/// Executes the resource filter.
/// Called asynchronously before the rest of the pipeline.
/// </summary>
/// <param name="context">The <see cref="ResourceExecutingContext"/>.</param>
/// <param name="next">
/// The <see cref="ResourceExecutionDelegate"/>. Invoked to execute the next
/// resource filter, or the remainder of the pipeline.
/// The <see cref="ResourceExecutionDelegate"/>. Invoked to execute the next resource filter or the remainder
/// of the pipeline.
/// </param>
/// <returns>
/// A <see cref="Task"/> which will complete when the remainder of the pipeline completes.

View File

@ -5,8 +5,19 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that asynchronously surrounds execution of the action result.
/// </summary>
public interface IAsyncResultFilter : IFilterMetadata
{
/// <summary>
/// Called asynchronously before the action result.
/// </summary>
/// <param name="context">The <see cref="ResultExecutingContext"/>.</param>
/// <param name="next">
/// The <see cref="ResultExecutionDelegate"/>. Invoked to execute the next result filter or the result itself.
/// </param>
/// <returns>A <see cref="Task"/> that on completion indicates the filter has executed.</returns>
Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next);
}
}

View File

@ -3,8 +3,15 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that confirms request authorization.
/// </summary>
public interface IAuthorizationFilter : IFilterMetadata
{
/// <summary>
/// Called early in the filter pipeline to confirm request is authorized.
/// </summary>
/// <param name="context">The <see cref="AuthorizationFilterContext"/>.</param>
void OnAuthorization(AuthorizationFilterContext context);
}
}

View File

@ -3,8 +3,15 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that runs after an action has thrown an <see cref="System.Exception"/>.
/// </summary>
public interface IExceptionFilter : IFilterMetadata
{
/// <summary>
/// Called after an action has thrown an <see cref="System.Exception"/>.
/// </summary>
/// <param name="context">The <see cref="ExceptionContext"/>.</param>
void OnException(ExceptionContext context);
}
}

View File

@ -3,8 +3,14 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that requires a reference back to the <see cref="IFilterFactory"/> that created it.
/// </summary>
public interface IFilterContainer
{
/// <summary>
/// The <see cref="IFilterFactory"/> that created this filter instance.
/// </summary>
IFilterMetadata FilterDefinition { get; set; }
}
}

View File

@ -6,7 +6,7 @@ using System;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// An interface for for filter metadata which can create an instance of an executable filter.
/// An interface for filter metadata which can create an instance of an executable filter.
/// </summary>
public interface IFilterFactory : IFilterMetadata
{

View File

@ -3,6 +3,9 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// Marker interface for filters handled in the MVC request pipeline.
/// </summary>
public interface IFilterMetadata
{
}

View File

@ -3,6 +3,10 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A <see cref="FilterItem"/> provider. Implementations should update <see cref="FilterProviderContext.Results"/>
/// to make executable filters available.
/// </summary>
public interface IFilterProvider
{
/// <summary>
@ -26,8 +30,16 @@ namespace Microsoft.AspNetCore.Mvc.Filters
/// </remarks>
int Order { get; }
/// <summary>
/// Called in increasing <see cref="Order"/>.
/// </summary>
/// <param name="context">The <see cref="FilterProviderContext"/>.</param>
void OnProvidersExecuting(FilterProviderContext context);
/// <summary>
/// Called in decreasing <see cref="Order"/>, after all <see cref="IFilterProvider"/>s have executed once.
/// </summary>
/// <param name="context">The <see cref="FilterProviderContext"/>.</param>
void OnProvidersExecuted(FilterProviderContext context);
}
}

View File

@ -3,6 +3,9 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that specifies the relative order it should run.
/// </summary>
public interface IOrderedFilter : IFilterMetadata
{
/// <summary>
@ -23,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters
/// Synchronous filters, such as <see cref="IActionFilter"/>, have a before-method, such as
/// <see cref="IActionFilter.OnActionExecuting"/>, and an after-method, such as
/// <see cref="IActionFilter.OnActionExecuted"/>. A synchronous filter with a lower numeric <see cref="Order"/>
/// value will have its before-method executed before that of a filter with a higher value of
/// value will have its before-method executed before that of a filter with a higher value of
/// <see cref="Order"/>. During the after-stage of the filter, a synchronous filter with a lower
/// numeric <see cref="Order"/> value will have its after-method executed after that of a filter with a higher
/// value of <see cref="Order"/>.

View File

@ -4,7 +4,7 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter which surrounds execution of model binding, the action (and filters) and the action result
/// A filter that surrounds execution of model binding, the action (and filters) and the action result
/// (and filters).
/// </summary>
public interface IResourceFilter : IFilterMetadata

View File

@ -3,10 +3,21 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A filter that surrounds execution of the action result.
/// </summary>
public interface IResultFilter : IFilterMetadata
{
/// <summary>
/// Called before the action result executes.
/// </summary>
/// <param name="context">The <see cref="ResultExecutingContext"/>.</param>
void OnResultExecuting(ResultExecutingContext context);
/// <summary>
/// Called after the action result executes.
/// </summary>
/// <param name="context">The <see cref="ResultExecutedContext"/>.</param>
void OnResultExecuted(ResultExecutedContext context);
}
}

View File

@ -8,7 +8,7 @@ using System.Runtime.ExceptionServices;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A context for resource filters.
/// A context for resource filters, specifically <see cref="IResourceFilter.OnResourceExecuted"/> calls.
/// </summary>
public class ResourceExecutedContext : FilterContext
{
@ -36,10 +36,13 @@ namespace Microsoft.AspNetCore.Mvc.Filters
/// Gets or set the current <see cref="Exception"/>.
/// </summary>
/// <remarks>
/// <para>
/// Setting <see cref="Exception"/> or <see cref="ExceptionDispatchInfo"/> to <c>null</c> will treat
/// the exception as handled, and it will not be rethrown by the runtime.
///
/// </para>
/// <para>
/// Setting <see cref="ExceptionHandled"/> to <c>true</c> will also mark the exception as handled.
/// </para>
/// </remarks>
public virtual Exception Exception
{
@ -66,10 +69,13 @@ namespace Microsoft.AspNetCore.Mvc.Filters
/// Gets or set the current <see cref="Exception"/>.
/// </summary>
/// <remarks>
/// <para>
/// Setting <see cref="Exception"/> or <see cref="ExceptionDispatchInfo"/> to <c>null</c> will treat
/// the exception as handled, and it will not be rethrown by the runtime.
///
/// </para>
/// <para>
/// Setting <see cref="ExceptionHandled"/> to <c>true</c> will also mark the exception as handled.
/// </para>
/// </remarks>
public virtual ExceptionDispatchInfo ExceptionDispatchInfo
{
@ -86,10 +92,13 @@ namespace Microsoft.AspNetCore.Mvc.Filters
}
/// <summary>
/// <para>
/// Gets or sets a value indicating whether or not the current <see cref="Exception"/> has been handled.
///
/// </para>
/// <para>
/// If <c>false</c> the <see cref="Exception"/> will be rethrown by the runtime after resource filters
/// have executed.
/// </para>
/// </summary>
public virtual bool ExceptionHandled { get; set; }
@ -97,11 +106,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters
/// Gets or sets the result.
/// </summary>
/// <remarks>
/// <para>
/// The <see cref="Result"/> may be provided by execution of the action itself or by another
/// filter.
///
/// filter.
/// </para>
/// <para>
/// The <see cref="Result"/> has already been written to the response before being made available
/// to resource filters.
/// </para>
/// </remarks>
public virtual IActionResult Result { get; set; }
}

View File

@ -6,7 +6,8 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A context for resource filters.
/// A context for resource filters, specifically <see cref="IResourceFilter.OnResourceExecuting"/> and
/// <see cref="IAsyncResourceFilter.OnResourceExecutionAsync"/> calls.
/// </summary>
public class ResourceExecutingContext : FilterContext
{
@ -19,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters
: base(actionContext, filters)
{
}
/// <summary>
/// Gets or sets the result of the action to be executed.
/// </summary>

View File

@ -6,8 +6,9 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A delegate which asyncronously returns a <see cref="ResourceExecutedContext"/>.
/// A delegate that asynchronously returns a <see cref="ResourceExecutedContext"/> indicating model binding, the
/// action, the action's result, result filters, and exception filters have executed.
/// </summary>
/// <returns>A <see cref="ResourceExecutedContext"/>.</returns>
/// <returns>A <see cref="Task"/> that on completion returns a <see cref="ResourceExecutedContext"/>.</returns>
public delegate Task<ResourceExecutedContext> ResourceExecutionDelegate();
}

View File

@ -7,11 +7,23 @@ using System.Runtime.ExceptionServices;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A context for result filters, specifically <see cref="IResultFilter.OnResultExecuted"/> calls.
/// </summary>
public class ResultExecutedContext : FilterContext
{
private Exception _exception;
private ExceptionDispatchInfo _exceptionDispatchInfo;
/// <summary>
/// Instantiates a new <see cref="ResultExecutedContext"/> instance.
/// </summary>
/// <param name="actionContext">The <see cref="ActionContext"/>.</param>
/// <param name="filters">All applicable <see cref="IFilterMetadata"/> implementations.</param>
/// <param name="result">
/// The <see cref="IActionResult"/> copied from <see cref="ResultExecutingContext.Result"/>.
/// </param>
/// <param name="controller">The controller instance containing the action.</param>
public ResultExecutedContext(
ActionContext actionContext,
IList<IFilterMetadata> filters,
@ -28,10 +40,21 @@ namespace Microsoft.AspNetCore.Mvc.Filters
Controller = controller;
}
/// <summary>
/// Gets or sets an indication that a result filter set <see cref="ResultExecutingContext.Cancel"/> to
/// <c>true</c> and short-circuited the filter pipeline.
/// </summary>
public virtual bool Canceled { get; set; }
/// <summary>
/// Gets the controller instance containing the action.
/// </summary>
public virtual object Controller { get; }
/// <summary>
/// Gets or sets the <see cref="System.Exception"/> caught while executing the result or result filters, if
/// any.
/// </summary>
public virtual Exception Exception
{
get
@ -53,6 +76,10 @@ namespace Microsoft.AspNetCore.Mvc.Filters
}
}
/// <summary>
/// Gets or sets the <see cref="System.Runtime.ExceptionServices.ExceptionDispatchInfo"/> for the
/// <see cref="Exception"/>, if an <see cref="System.Exception"/> was caught and this information captured.
/// </summary>
public virtual ExceptionDispatchInfo ExceptionDispatchInfo
{
get
@ -67,8 +94,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters
}
}
/// <summary>
/// Gets or sets an indication that the <see cref="Exception"/> has been handled.
/// </summary>
public virtual bool ExceptionHandled { get; set; }
public virtual IActionResult Result { get; private set; }
/// <summary>
/// Gets the <see cref="IActionResult"/> copied from <see cref="ResultExecutingContext.Result"/>.
/// </summary>
public virtual IActionResult Result { get; }
}
}

View File

@ -5,8 +5,19 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A context for result filters, specifically <see cref="IResultFilter.OnResultExecuting"/> and
/// <see cref="IAsyncResultFilter.OnResultExecutionAsync"/> calls.
/// </summary>
public class ResultExecutingContext : FilterContext
{
/// <summary>
/// Instantiates a new <see cref="ResultExecutingContext"/> instance.
/// </summary>
/// <param name="actionContext">The <see cref="ActionContext"/>.</param>
/// <param name="filters">All applicable <see cref="IFilterMetadata"/> implementations.</param>
/// <param name="result">The <see cref="IActionResult"/> of the action and action filters.</param>
/// <param name="controller">The controller instance containing the action.</param>
public ResultExecutingContext(
ActionContext actionContext,
IList<IFilterMetadata> filters,
@ -18,10 +29,20 @@ namespace Microsoft.AspNetCore.Mvc.Filters
Controller = controller;
}
/// <summary>
/// Gets the controller instance containing the action.
/// </summary>
public virtual object Controller { get; }
/// <summary>
/// Gets or sets the <see cref="IActionResult"/> to execute. Setting <see cref="Result"/> to a non-<c>null</c>
/// value inside a result filter will short-circuit the result and any remaining result filters.
/// </summary>
public virtual IActionResult Result { get; set; }
/// <summary>
/// Gets or sets an indication the result filter pipeline should be short-circuited.
/// </summary>
public virtual bool Cancel { get; set; }
}
}

View File

@ -5,5 +5,10 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// A delegate that asynchronously returns an <see cref="ResultExecutedContext"/> indicating the action result or
/// the next result filter has executed.
/// </summary>
/// <returns>A <see cref="Task"/> that on completion returns an <see cref="ResultExecutedContext"/>.</returns>
public delegate Task<ResultExecutedContext> ResultExecutionDelegate();
}

View File

@ -13,12 +13,14 @@ using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Mvc.Authorization
{
/// <summary>
/// An implementation of <see cref="IAsyncAuthorizationFilter"/>
/// An implementation of <see cref="IAsyncAuthorizationFilter"/> which applies a specific
/// <see cref="AuthorizationPolicy"/>. MVC recognizes the <see cref="AuthorizeAttribute"/> and adds an instance of
/// this filter to the associated action or controller.
/// </summary>
public class AuthorizeFilter : IAsyncAuthorizationFilter
{
/// <summary>
/// Authorize filter for a specific policy.
/// Initialize a new <see cref="AuthorizeFilter"/> instance.
/// </summary>
/// <param name="policy">Authorization policy to be used.</param>
public AuthorizeFilter(AuthorizationPolicy policy)
@ -32,9 +34,9 @@ namespace Microsoft.AspNetCore.Mvc.Authorization
}
/// <summary>
/// Authorization policy to be used.
/// Gets the authorization policy to be used.
/// </summary>
public AuthorizationPolicy Policy { get; private set; }
public AuthorizationPolicy Policy { get; }
/// <inheritdoc />
public virtual async Task OnAuthorizationAsync(Filters.AuthorizationFilterContext context)

View File

@ -16,7 +16,8 @@ using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Specifies the allowed content types which can be used to select the action based on request's content-type.
/// A filter that specifies the supported request content types. <see cref="ContentTypes"/> is used to select an
/// action when there would otherwise be multiple matches.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class ConsumesAttribute :
@ -54,7 +55,10 @@ namespace Microsoft.AspNetCore.Mvc
/// <inheritdoc />
int IActionConstraint.Order { get; } = ConsumesActionConstraintOrder;
/// <inheritdoc />
/// <summary>
/// Gets or sets the supported request content types. Used to select an action when there would otherwise be
/// multiple matches.
/// </summary>
public MediaTypeCollection ContentTypes { get; set; }
/// <inheritdoc />
@ -103,6 +107,7 @@ namespace Microsoft.AspNetCore.Mvc
}
}
/// <inheritdoc />
public bool Accept(ActionConstraintContext context)
{
// If this constraint is not closest to the action, it will be skipped.

View File

@ -6,20 +6,31 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// An abstract filter that asynchronously surrounds execution of the action and the action result. Subclasses
/// should override <see cref="OnActionExecuting"/>, <see cref="OnActionExecuted"/> or
/// <see cref="OnActionExecutionAsync"/> but not <see cref="OnActionExecutionAsync"/> and either of the other two.
/// Similarly subclasses should override <see cref="OnResultExecuting"/>, <see cref="OnResultExecuted"/> or
/// <see cref="OnResultExecutionAsync"/> but not <see cref="OnResultExecutionAsync"/> and either of the other two.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class ActionFilterAttribute :
Attribute, IActionFilter, IAsyncActionFilter, IResultFilter, IAsyncResultFilter, IOrderedFilter
{
/// <inheritdoc />
public int Order { get; set; }
/// <inheritdoc />
public virtual void OnActionExecuting(ActionExecutingContext context)
{
}
/// <inheritdoc />
public virtual void OnActionExecuted(ActionExecutedContext context)
{
}
/// <inheritdoc />
public virtual async Task OnActionExecutionAsync(
ActionExecutingContext context,
ActionExecutionDelegate next)
@ -41,14 +52,17 @@ namespace Microsoft.AspNetCore.Mvc.Filters
}
}
/// <inheritdoc />
public virtual void OnResultExecuting(ResultExecutingContext context)
{
}
/// <inheritdoc />
public virtual void OnResultExecuted(ResultExecutedContext context)
{
}
/// <inheritdoc />
public virtual async Task OnResultExecutionAsync(
ResultExecutingContext context,
ResultExecutionDelegate next)

View File

@ -7,11 +7,17 @@ using Microsoft.AspNetCore.Mvc.Internal;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// An abstract filter that runs asynchronously after an action has thrown an <see cref="Exception"/>. Subclasses
/// must override <see cref="OnException"/> or <see cref="OnExceptionAsync"/> but not both.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class ExceptionFilterAttribute : Attribute, IAsyncExceptionFilter, IExceptionFilter, IOrderedFilter
{
/// <inheritdoc />
public int Order { get; set; }
/// <inheritdoc />
public virtual Task OnExceptionAsync(ExceptionContext context)
{
if (context == null)
@ -23,6 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters
return TaskCache.CompletedTask;
}
/// <inheritdoc />
public virtual void OnException(ExceptionContext context)
{
}

View File

@ -4,10 +4,13 @@
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// <para>
/// Contains constant values for known filter scopes.
///
/// </para>
/// <para>
/// Scope defines the ordering of filters that have the same order. Scope is by-default
/// defined by how a filter is registered.
/// </para>
/// </summary>
public static class FilterScope
{

View File

@ -6,19 +6,28 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Filters
{
/// <summary>
/// An abstract filter that asynchronously surrounds execution of the action result. Subclasses
/// must override <see cref="OnResultExecuting"/>, <see cref="OnResultExecuted"/> or
/// <see cref="OnResultExecutionAsync"/> but not <see cref="OnResultExecutionAsync"/> and either of the other two.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class ResultFilterAttribute : Attribute, IResultFilter, IAsyncResultFilter, IOrderedFilter
{
/// <inheritdoc />
public int Order { get; set; }
/// <inheritdoc />
public virtual void OnResultExecuting(ResultExecutingContext context)
{
}
/// <inheritdoc />
public virtual void OnResultExecuted(ResultExecutedContext context)
{
}
/// <inheritdoc />
public virtual async Task OnResultExecutionAsync(
ResultExecutingContext context,
ResultExecutionDelegate next)

View File

@ -9,7 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// A filter which will use the format value in the route data or query string to set the content type on an
/// A filter that will use the format value in the route data or query string to set the content type on an
/// <see cref="ObjectResult" /> returned from an action.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]

View File

@ -11,8 +11,8 @@ using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Mvc.Formatters
{
/// <summary>
/// A filter which will use the format value in the route data or query string to set the content type on an
/// <see cref="ObjectResult" /> returned from an action.
/// A filter that will use the format value in the route data or query string to set the content type on an
/// <see cref="ObjectResult"/> returned from an action.
/// </summary>
public class FormatFilter : IFormatFilter, IResourceFilter, IResultFilter
{

View File

@ -6,12 +6,12 @@ using Microsoft.AspNetCore.Mvc.Filters;
namespace Microsoft.AspNetCore.Mvc.Formatters.Internal
{
/// <summary>
/// A filter which produces a desired content type for the current request.
/// A filter that produces the desired content type for the request.
/// </summary>
public interface IFormatFilter : IFilterMetadata
{
/// <summary>
/// Gets the format value for the request associated with the provided <see cref="ActionContext"/>.
/// Gets the format value for the request associated with the provided <see cref="ActionContext"/>.
/// </summary>
/// <param name="context">The <see cref="ActionContext"/> associated with the current request.</param>
/// <returns>A format value, or <c>null</c> if a format cannot be determined for the request.</returns>

View File

@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
set { _cacheVaryByHeader = value; }
}
// <inheritdoc />
/// <inheritdoc />
public void OnActionExecuting(ActionExecutingContext context)
{
if (context == null)
@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
}
}
// <inheritdoc />
/// <inheritdoc />
public void OnActionExecuted(ActionExecutedContext context)
{
}

View File

@ -1,15 +1,13 @@
// 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 Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Mvc.ModelBinding
{
/// <summary>
/// A filter that scans for <see cref="UnsupportedContentTypeException"/> in the
/// <see cref="ActionContext.ModelState"/> and shortcircuits the pipeline
/// <see cref="ActionContext.ModelState"/> and short-circuits the pipeline
/// with an Unsupported Media Type (415) response.
/// </summary>
public class UnsupportedContentTypeFilter : IActionFilter

View File

@ -15,8 +15,9 @@ using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Specifies the allowed content types and the type of the value returned by the action
/// which can be used to select a formatter while executing <see cref="ObjectResult"/>.
/// A filter that specifies the expected <see cref="System.Type"/> the action will return and the supported
/// response content types. The <see cref="ContentTypes"/> value is used to set
/// <see cref="ObjectResult.ContentTypes"/>.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class ProducesAttribute : ResultFilterAttribute, IApiResponseMetadataProvider
@ -60,12 +61,18 @@ namespace Microsoft.AspNetCore.Mvc
ContentTypes = GetContentTypes(contentType, additionalContentTypes);
}
/// <inheritdoc />
public Type Type { get; set; }
/// <summary>
/// Gets or sets the supported response content types. Used to set <see cref="ObjectResult.ContentTypes"/>.
/// </summary>
public MediaTypeCollection ContentTypes { get; set; }
/// <inheritdoc />
public int StatusCode => StatusCodes.Status200OK;
/// <inheritdoc />
public override void OnResultExecuting(ResultExecutingContext context)
{
if (context == null)
@ -109,6 +116,7 @@ namespace Microsoft.AspNetCore.Mvc
return contentTypes;
}
/// <inheritdoc />
public void SetContentTypes(MediaTypeCollection contentTypes)
{
contentTypes.Clear();

View File

@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Mvc.Formatters;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Specifies the type of the value and status code returned by the action.
/// A filter that specifies the type of the value and status code returned by the action.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class ProducesResponseTypeAttribute : Attribute, IApiResponseMetadataProvider, IFilterMetadata
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Mvc
/// Initializes an instance of <see cref="ProducesResponseTypeAttribute"/>.
/// </summary>
/// <param name="type">The <see cref="Type"/> of object that is going to be written in the response.</param>
/// <param name="statusCode">HTTP response status code</param>
/// <param name="statusCode">The HTTP response status code.</param>
public ProducesResponseTypeAttribute(Type type, int statusCode)
{
if (type == null)

View File

@ -9,11 +9,23 @@ using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// An authorization filter that confirms requests are received over HTTPS.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class RequireHttpsAttribute : Attribute, IAuthorizationFilter, IOrderedFilter
{
/// <inheritdoc />
public int Order { get; set; }
/// <summary>
/// Called early in the filter pipeline to confirm request is authorized. Confirms requests are received over
/// HTTPS. Takes no action for HTTPS requests. Otherwise if it was a GET request, sets
/// <see cref="AuthorizationFilterContext.Result"/> to a result which will redirect the client to the HTTPS
/// version of the request URI. Otherwise, sets <see cref="AuthorizationFilterContext.Result"/> to a result
/// which will set the status code to <c>403</c> (Forbidden).
/// </summary>
/// <inheritdoc />
public virtual void OnAuthorization(AuthorizationFilterContext filterContext)
{
if (filterContext == null)
@ -27,6 +39,17 @@ namespace Microsoft.AspNetCore.Mvc
}
}
/// <summary>
/// Called from <see cref="OnAuthorization"/> if the request is not received over HTTPS. Expectation is
/// <see cref="AuthorizationFilterContext.Result"/> will not be <c>null</c> after this method returns.
/// </summary>
/// <param name="filterContext">The <see cref="AuthorizationFilterContext"/> to update.</param>
/// <remarks>
/// If it was a GET request, default implementation sets <see cref="AuthorizationFilterContext.Result"/> to a
/// result which will redirect the client to the HTTPS version of the request URI. Otherwise, default
/// implementation sets <see cref="AuthorizationFilterContext.Result"/> to a result which will set the status
/// code to <c>403</c> (Forbidden).
/// </remarks>
protected virtual void HandleNonHttpsRequest(AuthorizationFilterContext filterContext)
{
// only redirect for GET requests, otherwise the browser might not propagate the verb and request
@ -52,7 +75,7 @@ namespace Microsoft.AspNetCore.Mvc
// clear the port
host = new HostString(host.Host);
}
var newUrl = string.Concat(
"https://",
host.ToUriComponent(),

View File

@ -88,6 +88,7 @@ namespace Microsoft.AspNetCore.Mvc
/// <inheritdoc />
public bool IsReusable => true;
/// <inheritdoc />
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
{
if (serviceProvider == null)

View File

@ -9,10 +9,26 @@ using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// A filter that finds another filter in an <see cref="IServiceProvider"/>.
/// </summary>
/// <remarks>
/// <para>
/// Primarily used in <see cref="M:FilterCollection.AddService"/> calls.
/// </para>
/// <para>
/// Similar to the <see cref="TypeFilterAttribute"/> in that both use constructor injection. Use
/// <see cref="TypeFilterAttribute"/> instead if the filter is not itself a service.
/// </para>
/// </remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
[DebuggerDisplay("ServiceFilter: Type={ServiceType} Order={Order}")]
public class ServiceFilterAttribute : Attribute, IFilterFactory, IOrderedFilter
{
/// <summary>
/// Instantiates a new <see cref="ServiceFilterAttribute"/> instance.
/// </summary>
/// <param name="type">The <see cref="Type"/> of filter to find.</param>
public ServiceFilterAttribute(Type type)
{
if (type == null)
@ -26,11 +42,15 @@ namespace Microsoft.AspNetCore.Mvc
/// <inheritdoc />
public int Order { get; set; }
public Type ServiceType { get; private set; }
/// <summary>
/// Gets the <see cref="Type"/> of filter to find.
/// </summary>
public Type ServiceType { get; }
/// <inheritdoc />
public bool IsReusable { get; set; }
/// <inheritdoc />
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
{
if (serviceProvider == null)

View File

@ -9,12 +9,29 @@ using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// A filter that creates another filter of type <see cref="ImplementationType"/>, retrieving missing constructor
/// arguments from dependency injection if available there.
/// </summary>
/// <remarks>
/// <para>
/// Primarily used in <see cref="M:FilterCollection.Add"/> calls.
/// </para>
/// <para>
/// Similar to the <see cref="ServiceFilterAttribute"/> in that both use constructor injection. Use
/// <see cref="ServiceFilterAttribute"/> instead if the filter is itself a service.
/// </para>
/// </remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
[DebuggerDisplay("TypeFilter: Type={ImplementationType} Order={Order}")]
public class TypeFilterAttribute : Attribute, IFilterFactory, IOrderedFilter
{
private ObjectFactory _factory;
/// <summary>
/// Instantiates a new <see cref="TypeFilterAttribute"/> instance.
/// </summary>
/// <param name="type">The <see cref="Type"/> of filter to create.</param>
public TypeFilterAttribute(Type type)
{
if (type == null)
@ -25,9 +42,19 @@ namespace Microsoft.AspNetCore.Mvc
ImplementationType = type;
}
/// <summary>
/// Gets or sets the non-service arguments to pass to the <see cref="ImplementationType"/> constructor.
/// </summary>
/// <remarks>
/// Service arguments are found in the dependency injection container i.e. this filter supports constructor
/// injection in addition to passing the given <see cref="Arguments"/>.
/// </remarks>
public object[] Arguments { get; set; }
public Type ImplementationType { get; private set; }
/// <summary>
/// Gets the <see cref="Type"/> of filter to create.
/// </summary>
public Type ImplementationType { get; }
/// <inheritdoc />
public int Order { get; set; }
@ -35,6 +62,7 @@ namespace Microsoft.AspNetCore.Mvc
/// <inheritdoc />
public bool IsReusable { get; set; }
/// <inheritdoc />
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
{
if (serviceProvider == null)

View File

@ -14,7 +14,7 @@ using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Mvc.Cors
{
/// <summary>
/// A filter which applies the given <see cref="CorsPolicy"/> and adds appropriate response headers.
/// A filter that applies the given <see cref="CorsPolicy"/> and adds appropriate response headers.
/// </summary>
public class CorsAuthorizationFilter : ICorsAuthorizationFilter
{
@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Mvc.Cors
private bool IsClosestToAction(IEnumerable<IFilterMetadata> filters)
{
// If there are multiple ICorsAuthorizationFilter which are defined at the class and
// If there are multiple ICorsAuthorizationFilter that are defined at the class and
// at the action level, the one closest to the action overrides the others.
// Since filterdescriptor collection is ordered (the last filter is the one closest to the action),
// we apply this constraint only if there is no ICorsAuthorizationFilter after this.

View File

@ -37,6 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.Cors.Internal
/// <inheritdoc />
public bool IsReusable => true;
/// <inheritdoc />
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
{
if (serviceProvider == null)

View File

@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc.Filters;
namespace Microsoft.AspNetCore.Mvc.Cors.Internal
{
/// <summary>
/// A filter which can be used to enable/disable cors support for a resource.
/// A filter that can be used to enable/disable CORS support for a resource.
/// </summary>
public interface ICorsAuthorizationFilter : IAsyncAuthorizationFilter, IOrderedFilter
{

View File

@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// An attribute which skips antiforgery token validation.
/// An filter that skips antiforgery token validation.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class IgnoreAntiforgeryTokenAttribute : Attribute, IAntiforgeryPolicy, IOrderedFilter

View File

@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc.Filters;
namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
{
/// <summary>
/// A filter which saves temp data.
/// A filter that saves temp data.
/// </summary>
public class SaveTempDataFilter : IResourceFilter, IResultFilter
{

View File

@ -3,13 +3,12 @@
using System;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Filter to prevent StatusCodePages middleware to handle responses.
/// A filter that prevents execution of the StatusCodePages middleware.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class SkipStatusCodePagesAttribute : Attribute, IResourceFilter

View File

@ -14,7 +14,8 @@ namespace Microsoft.AspNetCore.Mvc
/// and the action method will not execute.
/// </summary>
/// <remarks>
/// This attribute helps defend against cross-site request forgery. It won't prevent other forgery or tampering attacks.
/// This attribute helps defend against cross-site request forgery. It won't prevent other forgery or tampering
/// attacks.
/// </remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class ValidateAntiForgeryTokenAttribute : Attribute, IFilterFactory, IOrderedFilter
@ -25,6 +26,7 @@ namespace Microsoft.AspNetCore.Mvc
/// <inheritdoc />
public bool IsReusable => true;
/// <inheritdoc />
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
{
return serviceProvider.GetRequiredService<ValidateAntiforgeryTokenAuthorizationFilter>();

View File

@ -9,7 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Mvc.ViewFeatures
{
/// <summary>
/// Adds a filter which will save the <see cref="ITempDataDictionary"/> for a request.
/// A filter that saves the <see cref="ITempDataDictionary"/> for a request.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class SaveTempDataAttribute : Attribute, IFilterFactory, IOrderedFilter

View File

@ -9,19 +9,22 @@ using Microsoft.AspNetCore.Mvc.Filters;
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// An action filter which sets <see cref="ActionExecutedContext.Result"/> to an <see cref="ObjectResult"/>
/// An action filter that sets <see cref="ActionExecutedContext.Result"/> to an <see cref="ObjectResult"/>
/// if the exception type is <see cref="HttpResponseException"/>.
/// This filter runs immediately after the action.
/// </summary>
public class HttpResponseExceptionActionFilter : IActionFilter, IOrderedFilter
{
/// <inheritdoc />
// Return a high number by default so that it runs closest to the action.
public int Order { get; set; } = int.MaxValue - 10;
/// <inheritdoc />
public void OnActionExecuting(ActionExecutingContext context)
{
}
/// <inheritdoc />
public void OnActionExecuted(ActionExecutedContext context)
{
if (context == null)