【发布时间】:2016-09-06 17:24:55
【问题描述】:
我现在在 dotnet core 中创建了一个网站。该站点在 azure 中运行并托管。我已经设置了 ssl 证书,并将其绑定到站点。
我必须在 web.config 或启动中做些什么才能使 ssl 工作吗?
我看不到使用 https 的网站。我必须在启动时重定向吗?
这是我最终得到的结果:
在 startup.cs 中,configure()
app.Use(async (context, next) =>
{
if (context.Request.IsHttps)
{
await next();
}
else
{
var withHttps = "https://" + context.Request.Host + context.Request.Path;
context.Response.Redirect(withHttps);
}
});
【问题讨论】:
-
当您使用 https 浏览网站时,您会得到什么响应? (你看到了什么,http 状态码等)
标签: asp.net-core