using Microsoft.AspNetCore.Http; using System.Threading.Tasks; public class UrlEncodingMiddleware { private readonly RequestDelegate _next; public UrlEncodingMiddleware(RequestDelegate next) { _next = next; } public async Task InvokeAsync(HttpContext context) { if (context.Request.Path.Value != null && context.Request.Path.Value.StartsWith("/api", StringComparison.OrdinalIgnoreCase)) { if (context.Request.Path.Value.Contains(".")) { var newPath = context.Request.Path.Value.Replace(".", "%2E"); context.Request.Path = new PathString(newPath); } } await _next(context); } }