{"id":589,"date":"2019-09-24T15:20:01","date_gmt":"2019-09-24T06:20:01","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=589"},"modified":"2019-09-24T15:20:01","modified_gmt":"2019-09-24T06:20:01","slug":"hello-world-startup-basic-multiple","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=589","title":{"rendered":"hello-world-startup-basic-multiple"},"content":{"rendered":"\n<pre class=\"lang:c# decode:true \" >using Microsoft.AspNetCore.Hosting; \/\/IWebHostBuilder\r\nusing Microsoft.AspNetCore.Builder; \/\/IApplicationBuilder\r\nusing Microsoft.AspNetCore.Http; \/\/WriteAsync\r\nusing Microsoft.AspNetCore; \/\/webHost\r\nusing Microsoft.Extensions.Logging;\/\/ILoggerFactory\r\nusing Microsoft.Extensions.DependencyInjection; \/\/ IServiceCollection\r\n\r\nnamespace WebApplication1\r\n{\r\n    public class Startup1\r\n    {\r\n        public Startup1(IHostingEnvironment env, ILoggerFactory logger)\r\n        {\r\n            \/\/These are two services available at constructor\r\n        }\r\n\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            \/\/This is the only service available at ConfigureServices\r\n        }\r\n\r\n        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger)\r\n        {  \r\n            app.Run(context =&gt;\r\n            {   \r\n                return context.Response.WriteAsync(\"Hello from multi start1\");\r\n                \r\n            });\r\n        }\r\n    }\r\n\r\n    public class Startup2\r\n    {\r\n        public Startup2(IHostingEnvironment env, ILoggerFactory logger)\r\n        {\r\n            \/\/These are two services available at constructor\r\n        }\r\n\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            \/\/This is the only service available at ConfigureServices\r\n        }\r\n\r\n        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger)\r\n        {\r\n            \/\/These are the three default services available at Configure\r\n\r\n            app.Run(context =&gt;\r\n            {\r\n                return context.Response.WriteAsync(\"Hello world Startup2\");\r\n            });\r\n        }\r\n    }\r\n\r\n    public class Program\r\n    {\r\n        public static void Main(string[] args)\r\n        {\r\n            CreateWebHostBuilder(args).Build().Run();\r\n        }\r\n\r\n        public static IWebHostBuilder CreateWebHostBuilder(string[] args)\r\n        {\r\n            var hostBuilder = WebHost.CreateDefaultBuilder(args).UseEnvironment(\"Development\");\r\n            \/\/This is a dumb way of doing it. You can use command line argument, etc to switch your startup \r\n            const int startupNumber = 2; \/\/CHANGE THIS to 2 if you want to use Startup2\r\n\r\n            if (startupNumber == 1)\r\n                hostBuilder.UseStartup&lt;Startup1&gt;();\r\n            else if (startupNumber == 2)\r\n                hostBuilder.UseStartup&lt;Startup2&gt;();\r\n\r\n            return hostBuilder;\r\n\r\n        }\r\n            \r\n    }\r\n}<\/pre>\n<p>\uacb0\uacfc : Hello from multi start1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>using Microsoft.AspNetCore.Hosting; \/\/IWebHostBuilder using Microsoft.AspNetCore.Builder; \/\/IApplicationBuilder using Microsoft.AspNetCore.Http; \/\/WriteAsync using Microsoft.AspNetCore; \/\/webHost using Microsoft.Extensions.Logging;\/\/ILoggerFactory using Microsoft.Extensions.DependencyInjection; \/\/ IServiceCollection namespace WebApplication1 { public class Startup1 { public Startup1(IHostingEnvironment env, ILoggerFactory logger) { \/\/These are two services available at constructor } public void ConfigureServices(IServiceCollection services) { \/\/This is the only service available at ConfigureServices } public void\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=589\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[108],"tags":[],"class_list":["post-589","post","type-post","status-publish","format-standard","hentry","category-net-core"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=589"}],"version-history":[{"count":1,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/589\/revisions"}],"predecessor-version":[{"id":590,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/589\/revisions\/590"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}