asp.net - UseHttpsRedirection 和 UseHsts 有什么区别

标签 asp.net .net .net-core

我不太明白 UseHsts 之间的区别和 UseHttpsRedirection在 .net core 中启动文件的配置部分。谁能解释一下?

最佳答案

根据文档,您应该同时使用两者:

We recommend all production ASP.NET Core web apps call:

  • The HTTPS Redirection Middleware (UseHttpsRedirection) to redirect all HTTP requests to HTTPS.
  • UseHsts, HTTP Strict Transport Security Protocol (HSTS).


ASP.NET Core Enforce HTTPS
.UseHttpsRedirection()将发出从 http 重定向到 https 的 HTTP 响应代码。 .UseHsts()将添加 HSTS 响应 header which the client is supposed to obey.

关于asp.net - UseHttpsRedirection 和 UseHsts 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52556364/

相关文章:

c# - 为什么不能为泛型类型推断类型参数?

apache - .NET Core Web 应用程序 - app_offline 等效/安全停止 Web 应用程序进行维护

c# - 在 .NET Core Web API 上启用 CORS 的 OPTIONS header

c# - 文本属性中的全局资源

c# - session ["key"的字符串扩展方法]

c# - 手动将项目插入 ListView 控件

c# - 复杂功能的 TDD 方法

c# - Dropzone,如何提交包含数据和多张图片的表单?

.net - 查找性能 : Array, 列表还是字典?

.net - .Net Framework 项目是否会通过 .Net 5 实现跨平台