2016-05-20 6 views
4

特定の設定を使用してWebアプリケーションを実行するためにdotnet cliを使用して指定する方法を教えてください。 私はhosting.jsonを使うことができると知っていますが、これを行う方法とこれがどのようにdotnet cliに関連しているかのドキュメントは見つかりませんでした。このサンプルではdotnet特定のURLを使用してWebサイトを実行

+0

設定しようとしている設定を明確にすることはできますか?特定のポートまたはIPアドレスでリッスンさせようとしていますか?もしそうなら[この回答](http://stackoverflow.com/questions/37289816/how-to-start-a-asp-net-core-1-0-rc2-app-that-doesnt-listen-to-the -localhost/37289990#37289990)は役に立ちます –

答えて

7

ルック: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(); 
    } 

そして、特定のポートでのProgram.csに.UseUrlsを試してみてくださいdotnet run server.urls=http://localhost:5001/

+1

ありがとうございました。まさに私が欠けていたもの。今すぐ動作! – mbr

3

を呼び出します。

public class Program 
    { 
     public static void Main(string[] args) 
     { 
      var host = new WebHostBuilder() 
       .UseKestrel() 
       .UseContentRoot(Directory.GetCurrentDirectory()) 
       .UseIISIntegration() 
       .UseStartup<Startup>() 
       .UseUrls("http://localhost:5020") 
       .Build(); 

      host.Run(); 
     } 
    } 
関連する問題