asp.net-core - dotnet运行具有特定URL的网站

标签 asp.net-core dotnet-cli

如何指定使用dotnet cli通过特定配置运行我的Web应用程序。
我知道可以使用hosting.json,但是我没有找到任何文档以及如何与dotnet cli联系。

最佳答案

看一下这个样本:https://github.com/aspnet/Security/blob/dev/samples/CookieSample/Program.cs#L11

调整了命令行:

    public static void Main(string[] args)
    {
        var config = new ConfigurationBuilder().AddCommandLine(args).Build();

        var host = new WebHostBuilder()
            .UseKestrel()
            .UseConfiguration(config)
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();

        host.Run();
    }

然后调用dotnet run server.urls=http://localhost:5001/

关于asp.net-core - dotnet运行具有特定URL的网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37351310/

相关文章:

asp.net-core - 从 Razor 页面处理程序返回部分 View

c# - EF Core 搜索多列 null 错误

c# - 如何以 junit 格式记录 dotnet 测试输出

c# - 如何构建面向 .NET Core 的类库?

console-application - 您如何在 .net 核心控制台应用程序中存储用户应用程序数据

c# - 使用 NLog 在 ASP.NET Core 中记录异常

asp.net-core - 将 .NET Core 重新定位到 net471、net 472

c# - .NET — 管理不同版本的 NuGet 包的常见依赖关系

nuget - 使用用户凭据进行 dotnet nuget 推送

c# - 尝试将 .net 核心项目从 2.2 迁移到 3.1