У меня есть сервер 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
Устранение неполадок HTTPS с приложением .NET на сервере IIS ⇐ C#
Место общения программистов C#
-
Anonymous
1731296526
Anonymous
У меня есть сервер 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
}
}
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79170746/troubleshooting-https-issues-with-net-application-on-iis-server[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия