У меня есть сервер IIS со всеми установленными пакетами и всем необходимым...
Если я запускаю сборку локально, https работает, а на сервере ничего нет. Через PortScanner я вижу, что порт открыт, а EventManger показывает, что процесс начался.
Через http я вижу все, и там все работает, но не на https.
У меня тот же IIS, то же самое ssl-сертификат интерфейса с помощью vue3, и он работает нормально... Но здесь нет приложения .net... В чем, черт возьми, моя ошибка?
Program.cs
using BaseBackend.Controllers;
using Microsoft.AspNetCore.Authentication.Cookies;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews(); // For MVC support
builder.Services.AddControllers(); // For API support
// Configure Swagger/OpenAPI
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Register IConfiguration for DI
//builder.Services.AddSingleton(builder.Configuration);
// Register TuningDatabaseHandler for DI
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
// Configure Authentication
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = "/api/login";
options.LogoutPath = "/api/logout";
options.Cookie.HttpOnly = true;
});
// Configure Authorization
builder.Services.AddAuthorization();
// Configure CORS
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowFrontend", builder =>
{
builder.WithOrigins("https://localhost")
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
builder.Services.AddHttpsRedirection(options =>
{
options.HttpsPort = 44390; // Specify the HTTPS port where is same in IIS
});
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseSwagger();
app.UseSwaggerUI();
// Enable CORS policy
app.UseCors("AllowFrontend");
//app.UseHttpsRedirection();
// Use authentication and authorization middleware
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.MapGet("/", () => "Test Page: Application is Running!");
app.Run();
appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Swagger": {
"Enabled": true
},
"ConnectionStrings": {
"dbo": "Server=.\\SQLEXPRESS;Integrated Security=True;Database=dbo;"
},
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://localhost:44390" // Set HTTPS to listen on port 44390
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... iis-server