{"id":710,"date":"2019-10-07T14:52:39","date_gmt":"2019-10-07T05:52:39","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=710"},"modified":"2019-10-07T14:52:57","modified_gmt":"2019-10-07T05:52:57","slug":"710","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=710","title":{"rendered":"MVC routing-8"},"content":{"rendered":"\n<pre class=\"lang:c# decode:true \" >using Microsoft.AspNetCore.Hosting;\r\nusing Microsoft.AspNetCore.Builder;\r\nusing Microsoft.AspNetCore.Http;\r\nusing Microsoft.Extensions.Logging;\r\nusing Microsoft.Extensions.DependencyInjection;\r\nusing Microsoft.AspNetCore;\r\nusing Microsoft.Extensions.Configuration;\r\nusing Microsoft.AspNetCore.Mvc;\r\n\r\nnamespace MvcRouting\r\n{\r\n    public class Startup\r\n    {\r\n        public Startup(IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration)\r\n        {\r\n            \/\/These are three services available at constructor\r\n        }\r\n\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            services.AddMvcCore().\r\n                SetCompatibilityVersion(CompatibilityVersion.Version_2_1);\r\n        }\r\n\r\n        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration)\r\n        {\r\n            app.UseMvc();\r\n        }\r\n    }\r\n\r\n\r\n    [Route(\"[controller]\/[action]\")]\r\n    public class HomeController : Controller\r\n    {\r\n        [HttpGet(\"\/\")]\r\n        [HttpGet(\"\")]\r\n        public ActionResult Index()\r\n        {\r\n            return new ContentResult\r\n            {\r\n                Content = @\"\r\n                &lt;html&gt;&lt;body&gt;\r\n                &lt;h1&gt;[controller] and [action] replacement tokens examples&lt;\/h1&gt;\r\n                &lt;ul&gt;\r\n                    &lt;li&gt;&lt;a href=\"\"\/\"\"&gt;\/&lt;\/a&gt;&lt;\/li&gt;\r\n                    &lt;li&gt;&lt;a href=\"\"\/home\/index\"\"&gt;\/home\/index&lt;\/a&gt;&lt;\/li&gt;\r\n                    &lt;li&gt;&lt;a href=\"\"\/home\/about\"\"&gt;\/home\/about&lt;\/a&gt;&lt;\/li&gt;\r\n                    &lt;li&gt;&lt;a href=\"\"\/about\"\"&gt;\/about&lt;\/a&gt;&lt;\/li&gt;\r\n                &lt;\/ul&gt;\r\n                &lt;\/body&gt;&lt;\/html&gt;\",\r\n                ContentType = \"text\/html\"\r\n            };\r\n        }\r\n\r\n        public ActionResult About()\r\n        {\r\n            return new ContentResult\r\n            {\r\n                Content = @\"\r\n                &lt;html&gt;&lt;body&gt;\r\n                &lt;b&gt;About Page&lt;\/b\r\n                &lt;\/body&gt;&lt;\/html&gt;\",\r\n                ContentType = \"text\/html\"\r\n            };\r\n        }\r\n\r\n        [HttpGet(\"\/about\")]\r\n        public ActionResult About2()\r\n        {\r\n            return new ContentResult\r\n            {\r\n                Content = @\"\r\n                &lt;html&gt;&lt;body&gt;\r\n                &lt;b&gt;About Page 2&lt;\/b\r\n                &lt;\/body&gt;&lt;\/html&gt;\",\r\n                ContentType = \"text\/html\"\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 :<br \/>\n[controller] replacement token examples<br \/>\n\u2022\/<br \/>\n\u2022\/home\/<br \/>\n\u2022\/home\/about<br \/>\n\u2022\/about<\/p>\n","protected":false},"excerpt":{"rendered":"<p>using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore; using Microsoft.Extensions.Configuration; using Microsoft.AspNetCore.Mvc; namespace MvcRouting { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { \/\/These are three services available at constructor } public void ConfigureServices(IServiceCollection services) { services.AddMvcCore(). SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger,\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=710\">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-710","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\/710","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=710"}],"version-history":[{"count":2,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions"}],"predecessor-version":[{"id":712,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions\/712"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}