{"id":607,"date":"2019-09-24T16:31:37","date_gmt":"2019-09-24T07:31:37","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=607"},"modified":"2019-09-24T16:31:37","modified_gmt":"2019-09-24T07:31:37","slug":"hello-world-startup-basic-request-query-string-3","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=607","title":{"rendered":"hello-world-startup-basic-request-query-string-3"},"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\nusing Microsoft.Extensions.Primitives; \/\/StringValues\r\n\r\nnamespace WebApplication1\r\n{\r\n    public class Startup\r\n    {\r\n        public Startup(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(async context =&gt;\r\n            {\r\n                context.Response.Headers.Add(\"content-type\", \"text\/html\");\r\n\r\n                await context.Response.WriteAsync(\"&lt;html&gt;&lt;body&gt;\");\r\n                await context.Response.WriteAsync(\"&lt;h1&gt;All query string&lt;\/h1&gt;\");\r\n                await context.Response.WriteAsync(@\"&lt;a href=\"\"?message=hello&amp;message=world&amp;message=again&amp;isTrue=1&amp;morning=good\"\"&gt;click this link to add query string&lt;\/a&gt;&lt;br\/&gt;&lt;br\/&gt;\");\r\n                await context.Response.WriteAsync(\"&lt;ul&gt;\");\r\n                foreach (var v in context.Request.Query)\r\n                {\r\n                    string str = v.Value; \/\/implicit conversion from StringValues to String\r\n                    await context.Response.WriteAsync($\"&lt;li&gt;{v.Key} - {str}&lt;\/li&gt;\");\r\n                }\r\n                await context.Response.WriteAsync(\"&lt;\/ul&gt;\");\r\n                await context.Response.WriteAsync(\"&lt;\/body&gt;&lt;\/html&gt;\");\r\n            });\r\n        }\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) =&gt;\r\n            WebHost.CreateDefaultBuilder(args)\r\n                .UseStartup&lt;Startup&gt;()\r\n                .UseEnvironment(\"Development\"); \/\/You can change this to \"Production\" to use StartupProduction\r\n    }\r\n}<\/pre>\n<p>\uacb0\uacfc :<br \/>\nAll query string<br \/>\nclick this link to add query string<\/p>\n<p>\u2022message &#8211; hello,world,again<br \/>\n\u2022isTrue &#8211; 1<br \/>\n\u2022morning &#8211; good<\/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 using Microsoft.Extensions.Primitives; \/\/StringValues namespace WebApplication1 { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger) { \/\/These are two services available at constructor } public void ConfigureServices(IServiceCollection services) { \/\/This is the only service available at ConfigureServices\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=607\">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-607","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\/607","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=607"}],"version-history":[{"count":1,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/607\/revisions"}],"predecessor-version":[{"id":608,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/607\/revisions\/608"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}