/// <summary> /// Adds the X-Robots-Tag header to all responses. /// </summary> /// <param name="noIndex"></param> /// <param name="noFollow"></param> public static IServiceCollection AddXRobotsTag(this IServiceCollection services, bool noIndex = true, bool noFollow = true) { RobotsTagDirectives directives = noIndex ? noFollow ? RobotsTagDirectives.NoIndex | RobotsTagDirectives.NoFollow : RobotsTagDirectives.NoIndex : noFollow ? RobotsTagDirectives.NoFollow : RobotsTagDirectives.All ; return(services.AddXRobotsTag(new RobotsTagDirectiveList { Directives = directives, })); }
/// <summary> /// Adds the X-Robots-Tag header to all responses. /// </summary> /// <param name="app"></param> /// <param name="noIndex"></param> /// <param name="noFollow"></param> public static void UseXRobotsTag(this IApplicationBuilder app, bool noIndex = true, bool noFollow = true) { RobotsTagDirectives directives = noIndex ? noFollow ? RobotsTagDirectives.NoIndex | RobotsTagDirectives.NoFollow : RobotsTagDirectives.NoIndex : noFollow ? RobotsTagDirectives.NoFollow : RobotsTagDirectives.All ; app.UseXRobotsTag(new XRobotsTagHeaderValue { Directives = directives, }); }