public StaticRobotsTxtProvider(RobotsTxtOptions options) { var content = options.Build().ToString()?.TrimEnd(); if (string.IsNullOrWhiteSpace(content)) { content = "# This file didn't get any instructions so everyone is allowed"; } _content = Encoding.UTF8.GetBytes(content).AsMemory(); _maxAge = Convert.ToInt32(options.MaxAge.TotalSeconds); }
private async Task BuildRobotsTxt(HttpContext context) { var sb = _options.Build(); var output = sb.ToString()?.TrimEnd(); if (string.IsNullOrWhiteSpace(output)) { output = "# This file didn't get any instructions so everyone is allowed"; } var buffer = Encoding.UTF8.GetBytes(output); await context.Response.Body.WriteAsync(buffer, 0, buffer.Length); }