如何启动一个ASP.NET 1.0的核心RC2的应用程序,不听本地主机 [英] How to start a ASP.NET Core 1.0 RC2 app that doesn't listen to the localhost
问题描述
我怎么可以开始 ASP.NET核心与DOTNET CLI样本,使他们不听她的本地主机?
此命令不起作用:
DOTNET运行--server.urls = HTTP:// *:5000
你想做什么需要你的命令行参数添加到主要配置
应用程序的方法。加入这样的事情您创建 WebHostBuilder
对象之前:
VAR配置=新ConfigurationBuilder()
.AddCommandLine(参数)
。建立();
,然后调用之前添加此到 WebHostBuilder
对象 .Build()
就可以了:
.UseConfiguration(配置)
您还需要依赖添加到project.json:
Microsoft.Extensions.Configuration.CommandLine:1.0.0-RC2决赛,
最后,添加一个using语句到你的主
方法是在文件中:
使用Microsoft.Extensions.Configuration;
示例主
方法:
公共静态无效的主要(字串[] args)
{
无功配置=新ConfigurationBuilder()
.AddCommandLine(参数)
。建立(); VAR主机=新WebHostBuilder()
.UseKestrel()
.UseConfiguration(配置)
.UseStartup<&启动GT;()
。建立();
host.Run();
}
how can I start the ASP.NET Core with the dotnet CLI samples so that they don't listen to the localhost?
This command doesn't work:
dotnet run --server.urls=http://*:5000
What you're trying to do requires you to add command-line args to your configuration in the Main
method of your application. Add something like this before you create your WebHostBuilder
object:
var config = new ConfigurationBuilder()
.AddCommandLine(args)
.Build();
And then add this to the WebHostBuilder
object before calling .Build()
on it:
.UseConfiguration(config)
You'll also need to add a dependency to project.json:
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0-rc2-final",
And finally, add a using statement to the file that your Main
method is in:
using Microsoft.Extensions.Configuration;
Example Main
method:
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddCommandLine(args)
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseConfiguration(config)
.UseStartup<Startup>()
.Build();
host.Run();
}
这篇关于如何启动一个ASP.NET 1.0的核心RC2的应用程序,不听本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!