我目前正在使用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内,但是没有用
class program.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");
}
答案 0 :(得分:1)
我正在工作localhost测试实例。我不需要使用https,因此请禁用https。
class program.css
//.UseSetting("https_port", "5000")
startup.css类
//app.UseHsts();
答案 1 :(得分:0)
我们正在为在应用程序服务中的容器 中运行的ASP.NET Core应用程序解决一个已知问题。 here中描述了此问题,以及我们计划就今天如何解决该问题 向社区进行教育,以及我们计划如何进行长期修复。可能没有关系,但想将其放在此处以防万一。
答案 2 :(得分:0)
我能够通过以下方式在我的 asp.net 核心项目中修复此问题:
现在,当我调试应用程序时,它会自动启动到 https URL。
答案 3 :(得分:0)
我很可能迟到了,但也许这可能会帮助到其他人。 您可以说该错误几乎是不言自明的,您正在尝试使用不受支持的协议访问该站点。请确保您使用的是正确的协议,即如果您的站点是 http,那么请确保在浏览器上输入的 url 确实是 http,例如 https://localhost:8000 与 http://localhost:8000,注意字母 s 的区别在网址中。我遇到了这样的问题,改用正确的协议解决了我的问题。