在一个 ASP.NET Core 7.0 项目中,Program 中没有 app.UseHttpsRedirection()
,但请求 localhost 地址时依然强制跳转 https
root@8c6af80eeb1e:/app# curl -i localhost/
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Date: Fri, 03 Mar 2023 01:53:43 GMT
Server: Kestrel
Location: https://localhost/
是一个 url 重写规则引起的
var rewriteOptions = new RewriteOptions()
.AddRedirectToHttpsPermanent();