public PreviewDetectMiddleware(
            RequestDelegate next,
            PreviewDetectOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            options.AssertValid();

            _next    = next ?? throw new ArgumentNullException(nameof(next));
            _options = options;
        }
Example #2
0
        /// <summary>
        /// Adds middleware that detects requests from preview bots/services and redirects to the specified page.
        /// </summary>
        public static IApplicationBuilder UsePreviewDetector(this IApplicationBuilder app, PreviewDetectOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            options.AssertValid();

            return(app.UseMiddleware <PreviewDetectMiddleware>(options));
        }