我有一个作为 Azure AppService 运行的 ASP.Net Core 2.2 站点。作为配置的一部分,我有一个启用了仅 HTTPS设置的自定义域。
我还在我的 Appservice 上打开了Always on设置。
根据这篇文章 https://ruslany.net/2017/11/most-common-deployment-slot-swap-failures-and-how-to-fix-them/仅开启HTTPS时将忽略Always on设置结果,我的网站总是在第一次通话时冷启动。
根据同一篇文章,可以在 web.config 中设置规则条件,如果处理了 {warmup_request} ,则不处理重定向到 HTTPS规则。
但是,我的HTTPS 仅设置在 Azure 中的自定义域上,而不是 web.config 中的规则。
我在 startup.cs 中使用以下代码设置 RouteOptions:
services.Configure<RouteOptions>(options =>
{
options.LowercaseUrls = true;
});
并相信规则条件也可以在这里完成,options.ConstraintMap()
但我不确定表示以下内容所需的语法或方法:
<match url="(.*)" />
<conditions>
<add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
<add input="{REMOTE_ADDR}" pattern="^100?\." negate="true" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
任何有关如何执行此操作的帮助将不胜感激
谢谢