{"id":597,"date":"2019-09-24T16:15:48","date_gmt":"2019-09-24T07:15:48","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=597"},"modified":"2019-09-24T16:15:48","modified_gmt":"2019-09-24T07:15:48","slug":"hello-world-startup-basic-request-headers-names","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=597","title":{"rendered":"hello-world-startup-basic-request-headers-names"},"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.Net.Http.Headers;\r\nusing System.Reflection; \/\/List\r\nusing System;\r\nusing System.Collections.Generic; \/\/Type\r\nusing System.Linq; \/\/Where\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        private List&lt;FieldInfo&gt; GetConstants(Type type)\r\n        {\r\n            FieldInfo[] fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);\r\n\r\n            return fieldInfos.Where(fi =&gt; fi.IsLiteral &amp;&amp; !fi.IsInitOnly).ToList();\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(HeaderNames.ContentType, \"text\/html\");\r\n\r\n                await context.Response.WriteAsync(\"&lt;h1&gt;Request Headers from Microsoft.Net.Http.Headers.HeaderNames&lt;\/h1&gt;\");\r\n                await context.Response.WriteAsync(\"&lt;ul&gt;\");\r\n                foreach (var h in GetConstants(typeof(HeaderNames)))\r\n                {\r\n                    await context.Response.WriteAsync($\"&lt;li&gt;{h.Name} = {h.GetValue(h)}&lt;\/li&gt;\");\r\n                }\r\n                await context.Response.WriteAsync(\"&lt;\/ul&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                .UseUrls(\"http:\/\/*:1000\", \"http:\/\/*:5000\")\r\n                .UseEnvironment(\"Development\"); \/\/You can change this to \"Production\" to use StartupProduction\r\n    }\r\n}<\/pre>\n<p>\uacb0\uacfc :<br \/>\nRequest Headers from Microsoft.Net.Http.Headers.HeaderNames<br \/>\n\u2022Accept = Accept<br \/>\n\u2022AcceptCharset = Accept-Charset<br \/>\n\u2022AcceptEncoding = Accept-Encoding<br \/>\n\u2022AcceptLanguage = Accept-Language<br \/>\n\u2022AcceptRanges = Accept-Ranges<br \/>\n\u2022AccessControlAllowCredentials = Access-Control-Allow-Credentials<br \/>\n\u2022AccessControlAllowHeaders = Access-Control-Allow-Headers<br \/>\n\u2022AccessControlAllowMethods = Access-Control-Allow-Methods<br \/>\n\u2022AccessControlAllowOrigin = Access-Control-Allow-Origin<br \/>\n\u2022AccessControlExposeHeaders = Access-Control-Expose-Headers<br \/>\n\u2022AccessControlMaxAge = Access-Control-Max-Age<br \/>\n\u2022AccessControlRequestHeaders = Access-Control-Request-Headers<br \/>\n\u2022AccessControlRequestMethod = Access-Control-Request-Method<br \/>\n\u2022Age = Age<br \/>\n\u2022Allow = Allow<br \/>\n\u2022Authority = :authority<br \/>\n\u2022Authorization = Authorization<br \/>\n\u2022CacheControl = Cache-Control<br \/>\n\u2022Connection = Connection<br \/>\n\u2022ContentDisposition = Content-Disposition<br \/>\n\u2022ContentEncoding = Content-Encoding<br \/>\n\u2022ContentLanguage = Content-Language<br \/>\n\u2022ContentLength = Content-Length<br \/>\n\u2022ContentLocation = Content-Location<br \/>\n\u2022ContentMD5 = Content-MD5<br \/>\n\u2022ContentRange = Content-Range<br \/>\n\u2022ContentSecurityPolicy = Content-Security-Policy<br \/>\n\u2022ContentSecurityPolicyReportOnly = Content-Security-Policy-Report-Only<br \/>\n\u2022ContentType = Content-Type<br \/>\n\u2022Cookie = Cookie<br \/>\n\u2022Date = Date<br \/>\n\u2022ETag = ETag<br \/>\n\u2022Expires = Expires<br \/>\n\u2022Expect = Expect<br \/>\n\u2022From = From<br \/>\n\u2022Host = Host<br \/>\n\u2022IfMatch = If-Match<br \/>\n\u2022IfModifiedSince = If-Modified-Since<br \/>\n\u2022IfNoneMatch = If-None-Match<br \/>\n\u2022IfRange = If-Range<br \/>\n\u2022IfUnmodifiedSince = If-Unmodified-Since<br \/>\n\u2022LastModified = Last-Modified<br \/>\n\u2022Location = Location<br \/>\n\u2022MaxForwards = Max-Forwards<br \/>\n\u2022Method = :method<br \/>\n\u2022Origin = Origin<br \/>\n\u2022Path = :path<br \/>\n\u2022Pragma = Pragma<br \/>\n\u2022ProxyAuthenticate = Proxy-Authenticate<br \/>\n\u2022ProxyAuthorization = Proxy-Authorization<br \/>\n\u2022Range = Range<br \/>\n\u2022Referer = Referer<br \/>\n\u2022RetryAfter = Retry-After<br \/>\n\u2022Scheme = :scheme<br \/>\n\u2022Server = Server<br \/>\n\u2022SetCookie = Set-Cookie<br \/>\n\u2022Status = :status<br \/>\n\u2022StrictTransportSecurity = Strict-Transport-Security<br \/>\n\u2022TE = TE<br \/>\n\u2022Trailer = Trailer<br \/>\n\u2022TransferEncoding = Transfer-Encoding<br \/>\n\u2022Upgrade = Upgrade<br \/>\n\u2022UserAgent = User-Agent<br \/>\n\u2022Vary = Vary<br \/>\n\u2022Via = Via<br \/>\n\u2022Warning = Warning<br \/>\n\u2022WebSocketSubProtocols = Sec-WebSocket-Protocol<br \/>\n\u2022WWWAuthenticate = WWW-Authenticate<\/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.Net.Http.Headers; using System.Reflection; \/\/List using System; using System.Collections.Generic; \/\/Type using System.Linq; \/\/Where namespace WebApplication1 { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger) { \/\/These are two services available at constructor } public void ConfigureServices(IServiceCollection\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=597\">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-597","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\/597","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=597"}],"version-history":[{"count":1,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/597\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/597\/revisions\/598"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}