Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core http的ASP.NET Core 2.2错误连接被拒绝_Asp.net Core - Fatal编程技术网

Asp.net core http的ASP.NET Core 2.2错误连接被拒绝

Asp.net core http的ASP.NET Core 2.2错误连接被拒绝,asp.net-core,Asp.net Core,我正在努力让ASP.NET Core 2.2应用程序侦听http请求 当我启动应用程序时,dotnet运行--urlhttp://0.0.0.0:5000 命令返回正在侦听:https://[:]:5001 尝试访问url时:http://localhost:5000 我在浏览器中收到一条错误消息,说明错误连接被拒绝 Https连接在端口5001上工作,但在端口5000上Http失败。 我的launcSettings.json如下所示: "commandName": "Project", "

我正在努力让ASP.NET Core 2.2应用程序侦听http请求

当我启动应用程序时,
dotnet运行--urlhttp://0.0.0.0:5000
命令返回
正在侦听:https://[:]:5001

尝试访问url时:
http://localhost:5000

我在浏览器中收到一条错误消息,说明
错误连接被拒绝

Https连接在端口5001上工作,但在端口5000上Http失败。

我的
launcSettings.json
如下所示:

"commandName": "Project",
  "launchBrowser": true,
  "applicationUrl": "http://localhost:5000;https://localhost:5001",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
请通过建议如何启用http来提供帮助

我已在
Starup.cs
中禁用了HttpsRedirection,但这也没有效果:

        app.UseStatusCodePages();            
        //app.UseHttpsRedirection();
        app.UseStaticFiles();
        app.UseCookiePolicy();

要修复此情况,请确保
程序
类正确配置了WebHost

在下面的示例中,两个URL字符串
.useURL(“https://*:5001;http://*:5000”)
用于配置
WebHost
,确保服务在tcp端口5001和5000上同时接受https和http

e、 g

公共类程序
{
公共静态void Main(字符串[]args)
{
CreateWebHostBuilder(args.Build().Run();
}
公共静态IWebHostBuilder CreateWebHostBuilder(字符串[]args)=>
WebHost.CreateDefaultBuilder(args)
.useURL(“https://*:5001;http://*:5000”)
.UseStartup();
}

要解决此问题,请确保
程序
类正确配置了Web主机

在下面的示例中,两个URL字符串
.useURL(“https://*:5001;http://*:5000”)
用于配置
WebHost
,确保服务在tcp端口5001和5000上同时接受https和http

e、 g

公共类程序
{
公共静态void Main(字符串[]args)
{
CreateWebHostBuilder(args.Build().Run();
}
公共静态IWebHostBuilder CreateWebHostBuilder(字符串[]args)=>
WebHost.CreateDefaultBuilder(args)
.useURL(“https://*:5001;http://*:5000”)
.UseStartup();
}
public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseUrls("https://*:5001;http://*:5000")  
            .UseStartup<Startup>();
}