-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
29 lines (23 loc) · 718 Bytes
/
Program.cs
File metadata and controls
29 lines (23 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
builder.WebHost.ConfigureKestrel(opts =>
{
// Insecure HTTP endpoint
opts.ListenLocalhost(8080);
// Secure HTTPS endpoint (dev certificate)
opts.ListenLocalhost(8443, listenOpts => listenOpts.UseHttps());
});
var app = builder.Build();
// Optionally redirect HTTP → HTTPS globally
app.UseHttpsRedirection();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
app.Run();