/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Middleware/HttpsPolicy/sample/Startup.cs
72 строки
2 KB
Shreyas Jejurkar
chore : Remove unwanted `using` statement (#39176)
02 янв 2022, 17:39
Не верифицирован
02 янв 2022, 17:39
c85baf8
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Net; namespace HttpsSample; public class Startup { // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddHttpsRedirection(options => { options.RedirectStatusCode = StatusCodes.Status301MovedPermanently; options.HttpsPort = 5001; }); services.AddHsts(options => { options.MaxAge = TimeSpan.FromDays(30); options.Preload = true; options.IncludeSubDomains = true; }); } public void Configure(IApplicationBuilder app, IWebHostEnvironment environment) { if (!environment.IsDevelopment()) { app.UseHsts(); } app.UseHttpsRedirection(); app.Run(async context => { await context.Response.WriteAsync("Hello world!"); }); } // Entry point for the application. public static Task Main(string[] args) { var host = new HostBuilder() .ConfigureWebHost(webHostBuilder => { webHostBuilder .UseKestrel( options => { options.Listen(new IPEndPoint(IPAddress.Loopback, 5001), listenOptions => { listenOptions.UseHttps("testCert.pfx", "testPassword"); }); options.Listen(new IPEndPoint(IPAddress.Loopback, 5000), listenOptions => { }); }) .UseContentRoot(Directory.GetCurrentDirectory()) // for the cert file .ConfigureLogging(factory => { factory.SetMinimumLevel(LogLevel.Debug); factory.AddConsole(); }) .UseStartup<Startup>(); }) .Build(); return host.RunAsync(); } }