Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.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
C# 使用VS的2个不同端口运行Swagger UI_C#_Visual Studio_Swagger - Fatal编程技术网

C# 使用VS的2个不同端口运行Swagger UI

C# 使用VS的2个不同端口运行Swagger UI,c#,visual-studio,swagger,C#,Visual Studio,Swagger,我在VS2019有一个应用程序。 我想运行2个不同的API模块,带有swagger UI和不同的端口。 有人能帮我吗 您的API应该绑定了2个端口,然后在没有额外配置的情况下为这两个端口显示Swagger。。。 使用.NET Core的示例: launchSettings.json: "applicationUrl": "https://localhost:5001;http://localhost:5000" Program.cs: public class Program { pu

我在VS2019有一个应用程序。 我想运行2个不同的API模块,带有swagger UI和不同的端口。
有人能帮我吗

您的API应该绑定了2个端口,然后在没有额外配置的情况下为这两个端口显示Swagger。。。 使用.NET Core的示例:

launchSettings.json:

"applicationUrl": "https://localhost:5001;http://localhost:5000"
Program.cs:

public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
            });
}
-配置方法:

app.UseSwaggerUI(c =>
{
    c.SwaggerEndpoint("/swagger/v1/swagger.json", "NameOfAPI");
    c.RoutePrefix = string.Empty;
});

可以帮我制作两个不同的招摇过市的用户界面,它可以运行两个不同的版本V1和V2??
app.UseSwaggerUI(c =>
{
    c.SwaggerEndpoint("/swagger/v1/swagger.json", "NameOfAPI");
    c.RoutePrefix = string.Empty;
});