Exemplo n.º 1
0
        /// <summary>
        ///     Adds the e tag action filter.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="maxAgeSeconds">The maximum age seconds.</param>
        /// <param name="sharedMaxAgeSeconds">The shared maximum age seconds.</param>
        /// <returns>IMvcBuilder.</returns>
        public static IMvcBuilder AddETagActionFilter(this IMvcBuilder builder,
                                                      ILoggerFactory loggerFactory, int maxAgeSeconds = 600, int sharedMaxAgeSeconds = 84600
                                                      )
        {
            builder.AddFilter <ETagActionFilter>(o => { o.Filters.TryAdd(new ETagActionFilter(loggerFactory, maxAgeSeconds, sharedMaxAgeSeconds)); });

            return(builder);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Adds RFC 7807 Problem Details for HTTP APIs support.  We are using our <see cref="ValidateResourceActionFilter" />
        ///     which in turn will generate a <see cref="ValidationFailureResult" />
        ///     <para>Note this requires that <see cref="ApiBehaviorOptions.SuppressModelStateInvalidFilter" /> be true.</para>
        /// </summary>
        /// <seealso cref="ValidateResourceActionFilter" />
        /// <param name="builder">IMvcBuilder.</param>
        /// <returns>IMvcBuilder.</returns>
        public static IMvcBuilder AddValidateResourceActionFilter(this IMvcBuilder builder)
        {
            builder.Services.Configure <ApiBehaviorOptions>(o =>
            {
                //o.SuppressUseValidationProblemDetailsForInvalidModelStateResponses = true;
                o.SuppressModelStateInvalidFilter = true;
            }
                                                            );

            return(builder.AddFilter <ValidateResourceActionFilter>(order: 0));
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Adds the post location header result filter.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <returns>IMvcBuilder.</returns>
 public static IMvcBuilder AddPostLocationHeaderResultFilter(
     this IMvcBuilder builder
     )
 {
     return(builder.AddFilter <PostLocationHeaderResultFilter>(order: 100));
 }
Exemplo n.º 4
0
        /// <summary>
        ///     This filter will prevent errors from being logged when actions have been cancelled.
        ///     If Exception is an OperationCanceledException it is handled otherwise disregarded.
        ///     <para>
        ///         Note that when using fiddler (or maybe other proxies) and when using IISExpress (at this time)
        ///         HttpContext.RequestAborted.IsCancellationRequested is ALWAYS false.
        ///         In other words, this filter won't do a damn thing.
        ///     </para>
        /// </summary>
        /// <param name="builder">IMvcBuilder</param>
        /// <returns>IMvcBuilder.</returns>
        public static IMvcBuilder AddOperationCancelledExceptionFilter(this IMvcBuilder builder)
        {
            builder.AddFilter <OperationCanceledExceptionFilter>(order: 0);

            return(builder);
        }