c# - 此站点无法从 dotnet linux 提供安全连接 asp.net core
问题描述
我目前正在使用 asp.net core 2.1 开发一个 API。当我在 Windows 中使用 ide Visual Studio 2019 时,我在运行项目时没有问题,但现在我使用的是 manjaro linux 并且我使用 dotnet 控制台进行编译时出现错误: 此站点无法提供安全连接 err_ssl_protocol_error
我见过的大多数解决方案都是使用框架 asp.net 或更改 Visual Studio IDE 的选项,所以我无法在我的项目中实现它。我试过添加:
.UseSetting("https_port", "5000")
在 program.cs 中,但它不起作用
类程序.cs
public static void Main(string[] args)
{
var host = CreateWebHostBuilder(args).Build();
RunSeeding(host);//esta llamando el alimentador de la base de datos
host.Run();
}
private static void RunSeeding(IWebHost host)
{
var scopeFactory = host.Services.GetService<IServiceScopeFactory>();
using (var scope = scopeFactory.CreateScope())
{
var seeder = scope.ServiceProvider.GetService<SeedDb>();
seeder.SeedAsync().Wait();
}
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseSetting("https_port", "5000")
.UseStartup<Startup>();
configure.cs 类
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseMvc();
app.UseCors("AllowSpecificOrigin");
}
解决方案
我能够通过以下方式在我的 asp.net 核心项目上解决此问题:
- 通过右键单击解决方案资源管理器中的项目并选择属性来打开项目属性
- 打开调试选项卡
- 在“Web 服务器设置”下,选中“启用 SSL”
现在,当我调试应用程序时,它会自动启动到 https URL。
推荐阅读
- bash - 使用文件行作为参数执行命令的 Bash 脚本
- python - Python Pandas:分类变量上的 Group BY 函数
- python - stats.truncnorm.rvs 中的“ValueError:参数中的域错误”指的是什么?
- apache - Apache 403 禁止访问被拒绝
- postgresql - 查询结构与函数结果类型 postgresql 不匹配
- python - 如何使用 python 将 CSV 文件导入 SQLite3
- r - 我想在 R 中使用 Wolfram 中使用的函数 EllipticE( )、ElliptctcF( ) EllipticK( ) 函数
- javascript - 函数 if 和 for 循环 const 数组中的偶数
- vue.js - Vue:使用计算属性将参数从应用程序传递到组件并返回
- mysql - 如何仅实现子类专业化 EER