{"id":644,"date":"2019-09-25T16:50:21","date_gmt":"2019-09-25T07:50:21","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=644"},"modified":"2019-09-25T16:54:35","modified_gmt":"2019-09-25T07:54:35","slug":"middleware-5","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=644","title":{"rendered":"middleware-5"},"content":{"rendered":"<p>&nbsp;<\/p>\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\n\r\nnamespace WebApplication1\r\n{\r\n        public class Startup\r\n        {\r\n            public void Configure(IApplicationBuilder app)\r\n            {\r\n                app.Map(\"\/hello\", (IApplicationBuilder pp) =&gt; {\r\n                    \/\/nested\r\n                    app.Map(\"\/world\", (IApplicationBuilder ppa) =&gt; ppa.Run(context =&gt;\r\n                        context.Response.WriteAsync($\"Path: {context.Request.Path} - Path Base: {context.Request.PathBase}\")));\r\n\r\n                    pp.Run(context =&gt;\r\n                        context.Response.WriteAsync($\"Path: {context.Request.Path} - Path Base: {context.Request.PathBase}\"));\r\n                });\r\n\r\n                app.Run(context =&gt;\r\n                {\r\n                    context.Response.Headers.Add(\"content-type\", \"text\/html\");\r\n                    return context.Response.WriteAsync(@\"\r\n                       &lt;a href=\"\"\/hello\"\"&gt;\/hello&lt;\/a&gt; &lt;a href=\"\"\/hello\/world\"\"&gt;\/hello\/world&lt;\/a&gt;\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\");\r\n        }\r\n}<\/pre>\n<pre class=\"lang:default 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\n\r\nnamespace WebApplication1\r\n{\r\n        public class Startup\r\n        {\r\n            public void Configure(IApplicationBuilder app)\r\n            {\r\n                app.MapWhen(context =&gt; context.Request.Path.Value.Contains(\"\/hello\"),\r\n                 (IApplicationBuilder pp) =&gt; {\r\n                        \/\/nested\r\n                        app.Map(\"\/world\", (IApplicationBuilder ppa) =&gt; ppa.Run(context =&gt;\r\n                         context.Response.WriteAsync($\"Path: {context.Request.Path} - Path Base: {context.Request.PathBase}\")));\r\n\r\n                     pp.Run(context =&gt;\r\n                         context.Response.WriteAsync($\"Path: {context.Request.Path} - Path Base: {context.Request.PathBase}\"));\r\n                 });\r\n\r\n                app.Run(context =&gt;\r\n                {\r\n                    context.Response.Headers.Add(\"content-type\", \"text\/html\");\r\n                    return context.Response.WriteAsync(@\"\r\n                       &lt;a href=\"\"\/hello\"\"&gt;\/hello&lt;\/a&gt; &lt;a href=\"\"\/hello\/world\"\"&gt;\/hello\/world&lt;\/a&gt;\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\");\r\n        }\r\n}<\/pre>\n<p>\uacb0\uacfc : Path: \/world &#8211; Path Base: \/hello<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; using Microsoft.AspNetCore.Hosting; \/\/IWebHostBuilder using Microsoft.AspNetCore.Builder; \/\/IApplicationBuilder using Microsoft.AspNetCore.Http; \/\/WriteAsync using Microsoft.AspNetCore; \/\/webHost namespace WebApplication1 { public class Startup { public void Configure(IApplicationBuilder app) { app.Map(&#8220;\/hello&#8221;, (IApplicationBuilder pp) =&gt; { \/\/nested app.Map(&#8220;\/world&#8221;, (IApplicationBuilder ppa) =&gt; ppa.Run(context =&gt; context.Response.WriteAsync($&#8221;Path: {context.Request.Path} &#8211; Path Base: {context.Request.PathBase}&#8221;))); pp.Run(context =&gt; context.Response.WriteAsync($&#8221;Path: {context.Request.Path} &#8211; Path Base: {context.Request.PathBase}&#8221;)); }); app.Run(context =&gt; {\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=644\">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-644","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\/644","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=644"}],"version-history":[{"count":3,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/644\/revisions"}],"predecessor-version":[{"id":647,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/644\/revisions\/647"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}