1. 视频 https://www.bilibili.com/video/av33344382/?p=2
using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; namespace BlogDemo.Api { public class StartupProduction { public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddHttpsRedirection(options => { options.RedirectStatusCode = StatusCodes.Status307TemporaryRedirect; options.HttpsPort = 5001; }); services.AddHsts(options => { options.Preload = true; options.IncludeSubDomains = true; options.MaxAge = TimeSpan.FromDays(60); options.ExcludedHosts.Add("example.com"); options.ExcludedHosts.Add("www.example.com"); }); } public void Configure(IApplicationBuilder app) { app.UseHsts(); app.UseHttpsRedirection(); app.UseMvc(); } } }
原文地址:https://www.cnblogs.com/Ken-Cai/p/10344808.html
时间: 2024-10-13 00:07:06