{"id":794,"date":"2020-10-08T18:11:33","date_gmt":"2020-10-08T18:11:33","guid":{"rendered":"https:\/\/serkanseker.com\/?p=794"},"modified":"2020-12-07T16:03:58","modified_gmt":"2020-12-07T16:03:58","slug":"create-and-consume-asp-net-core-web-api","status":"publish","type":"post","link":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/","title":{"rendered":"Create And Consume ASP.NET Core Web API"},"content":{"rendered":"\n<p>Hello to everyone! In this article, I will show you how to develop and test web services using ASP.NET Core. At the end of this post you will learn how to create a web API project and test it in the browser.<\/p>\n\n\n\n<p>First of all, let&#8217;s briefly talk about what is ASP.NET Core.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is ASP.NET Core?<\/h2>\n\n\n\n<p>ASP.NET Core makes it easier for developers working on software development with .NET technologies to develop more responsive, reliable and extensible applications.<\/p>\n\n\n\n<p>ASP.NET Core has redesigned the entire ASP.NET infrastructure and combined it with Web API and MVC infrastructures.<\/p>\n\n\n\n<p>Thanks to ASP.NET Core technology, it is possible to create modern applications with less effort and cost in a shorter time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><br>Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/visualstudio.microsoft.com\/downloads\/?utm_medium=microsoft&amp;utm_source=docs.microsoft.com&amp;utm_campaign=inline+link&amp;utm_content=download+vs2019\" target=\"_blank\" rel=\"noreferrer noopener\">Visual Studio 2019 16.4 or later<\/a>&nbsp;with the&nbsp;<strong>ASP.NET and web development<\/strong>&nbsp;workload<\/li><li><a href=\"https:\/\/dotnet.microsoft.com\/download\/dotnet-core\/3.1\" target=\"_blank\" rel=\"noreferrer noopener\">.NET Core 3.1 SDK or later<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Create an <strong>ASP.NET Core Web API<\/strong> Project<\/h2>\n\n\n\n<p>After starting Visual Studio, click on <strong>Create a new project<\/strong> title on the screen that appears.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/serkanseker.com\/wp-content\/uploads\/2020\/10\/Visual-Studio-create-a-new-project.jpg\" alt=\"Visual Studio create a new project\" class=\"wp-image-796\" width=\"1024\" height=\"627\"\/><figcaption>Visual Studio create a new project<\/figcaption><\/figure><\/div>\n\n\n\n<p>Next, type Create an ASP.NET Core Web Application in the search bar and select the first option that appears and click Next. Make sure the selected language is C#.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/serkanseker.com\/wp-content\/uploads\/2020\/10\/Create-an-ASP.NET-Core-Web-Application.jpg\" alt=\"Create an ASP.NET Core Web Application\" class=\"wp-image-797\" width=\"1024\" height=\"627\"\/><figcaption>Create an ASP.NET Core Web Application<\/figcaption><\/figure><\/div>\n\n\n\n<p>Then select the <strong>Project Name<\/strong>, <strong>Location <\/strong>and <strong>Solution Name<\/strong> and click the create button.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/serkanseker.com\/wp-content\/uploads\/2020\/10\/ASP.NET-Core-Web-Application-Configure-Project.jpg\" alt=\"ASP.NET Core Web Application Configure Project\" class=\"wp-image-798\" width=\"1018\" height=\"624\"\/><figcaption>ASP.NET Core Web Application Configure Project<\/figcaption><\/figure><\/div>\n\n\n\n<p>Then select the API option in the window that opens. In addition, I removed the Configure for HTTPS option in order to avoid problems while testing this project with different tools.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/serkanseker.com\/wp-content\/uploads\/2020\/10\/Create-an-ASP.NET-Core-Web-Application-Configure-for-HTTPS.jpg\" alt=\"Create an ASP.NET Core Web Application Configure for HTTPS\" class=\"wp-image-799\" width=\"1019\" height=\"706\"\/><\/figure><\/div>\n\n\n\n<p>And our project is ready. The project comes ready as an example of the <strong>WeatherForecast.cs<\/strong> Model class and the <strong>WeatherForecastController.cs<\/strong> class inside the Controllers folder.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/serkanseker.com\/wp-content\/uploads\/2020\/10\/ASP.NET-Core-Web-Application-Project-Structure.jpg\" alt=\"ASP.NET Core Web Application Project Structure\" class=\"wp-image-802\" width=\"326\" height=\"612\"\/><figcaption>ASP.NET Core Web Application Project Structure<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Test the API<\/h2>\n\n\n\n<p>Let&#8217;s run and test it with the ready-made classes without any additions to the project. Run the project by pressing Ctrl + F5. Visual Studio will start a browser and run the project on localhost with a randomly selected port number.<\/p>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/serkanseker.com\/wp-content\/uploads\/2020\/10\/Test-API-in-localhost.jpg\" alt=\"Test API in localhost\" class=\"wp-image-795\" width=\"675\" height=\"423\"\/><\/figure><\/div>\n\n\n\n<p>Visual studio went to <strong>https:\/\/localhost:&lt;port&gt;\/weatherforecast<\/strong> and worked successfully.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this post I showed you how to create and run an ASP.NET Core Web API project. Then we examine the ASP.NET Core project structure and files. Stay blowing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I will show you how to develop and test web services using ASP.NET Core. At the end of this post you will learn how to create a web API project and test it in the browser.<\/p>\n","protected":false},"author":1,"featured_media":156,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[49],"tags":[50,51,52],"class_list":["post-794","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net","tag-asp-net","tag-asp-net-core","tag-web-api"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create And Consume ASP.NET Core Web API - Serkan Seker TR<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create And Consume ASP.NET Core Web API - Serkan Seker TR\" \/>\n<meta property=\"og:description\" content=\"I will show you how to develop and test web services using ASP.NET Core. At the end of this post you will learn how to create a web API project and test it in the browser.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/\" \/>\n<meta property=\"og:site_name\" content=\"Serkan Seker TR\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-08T18:11:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-07T16:03:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1\" \/>\n\t<meta property=\"og:image:height\" content=\"1\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"serkanadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"serkanadmin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/\"},\"author\":{\"name\":\"serkanadmin\",\"@id\":\"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5\"},\"headline\":\"Create And Consume ASP.NET Core Web API\",\"datePublished\":\"2020-10-08T18:11:33+00:00\",\"dateModified\":\"2020-12-07T16:03:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/\"},\"wordCount\":396,\"commentCount\":1,\"image\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg\",\"keywords\":[\"ASP.NET\",\"ASP.NET Core\",\"Web API\"],\"articleSection\":[\"ASP.NET\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/\",\"url\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/\",\"name\":\"Create And Consume ASP.NET Core Web API - Serkan Seker TR\",\"isPartOf\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg\",\"datePublished\":\"2020-10-08T18:11:33+00:00\",\"dateModified\":\"2020-12-07T16:03:58+00:00\",\"author\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5\"},\"breadcrumb\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#primaryimage\",\"url\":\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg\",\"contentUrl\":\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/serkanseker.com\/tr\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create And Consume ASP.NET Core Web API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/serkanseker.com\/tr\/#website\",\"url\":\"https:\/\/serkanseker.com\/tr\/\",\"name\":\"Serkan Seker TR\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/serkanseker.com\/tr\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5\",\"name\":\"serkanadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/93ddc1f96117bf468976afe93a077eda77de96bcdb48dc749903598a546786a3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/93ddc1f96117bf468976afe93a077eda77de96bcdb48dc749903598a546786a3?s=96&d=mm&r=g\",\"caption\":\"serkanadmin\"},\"sameAs\":[\"https:\/\/serkanseker.com\"],\"url\":\"https:\/\/serkanseker.com\/tr\/author\/serkanadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create And Consume ASP.NET Core Web API - Serkan Seker TR","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Create And Consume ASP.NET Core Web API - Serkan Seker TR","og_description":"I will show you how to develop and test web services using ASP.NET Core. At the end of this post you will learn how to create a web API project and test it in the browser.","og_url":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/","og_site_name":"Serkan Seker TR","article_published_time":"2020-10-08T18:11:33+00:00","article_modified_time":"2020-12-07T16:03:58+00:00","og_image":[{"url":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg","width":1,"height":1,"type":"image\/jpeg"}],"author":"serkanadmin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"serkanadmin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#article","isPartOf":{"@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/"},"author":{"name":"serkanadmin","@id":"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5"},"headline":"Create And Consume ASP.NET Core Web API","datePublished":"2020-10-08T18:11:33+00:00","dateModified":"2020-12-07T16:03:58+00:00","mainEntityOfPage":{"@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/"},"wordCount":396,"commentCount":1,"image":{"@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#primaryimage"},"thumbnailUrl":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg","keywords":["ASP.NET","ASP.NET Core","Web API"],"articleSection":["ASP.NET"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/","url":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/","name":"Create And Consume ASP.NET Core Web API - Serkan Seker TR","isPartOf":{"@id":"https:\/\/serkanseker.com\/tr\/#website"},"primaryImageOfPage":{"@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#primaryimage"},"image":{"@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#primaryimage"},"thumbnailUrl":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg","datePublished":"2020-10-08T18:11:33+00:00","dateModified":"2020-12-07T16:03:58+00:00","author":{"@id":"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5"},"breadcrumb":{"@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#primaryimage","url":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg","contentUrl":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/10\/Create-And-Consume-ASP.NET-Core-Web-API.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/serkanseker.com\/tr\/create-and-consume-asp-net-core-web-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/serkanseker.com\/tr\/"},{"@type":"ListItem","position":2,"name":"Create And Consume ASP.NET Core Web API"}]},{"@type":"WebSite","@id":"https:\/\/serkanseker.com\/tr\/#website","url":"https:\/\/serkanseker.com\/tr\/","name":"Serkan Seker TR","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/serkanseker.com\/tr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5","name":"serkanadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/93ddc1f96117bf468976afe93a077eda77de96bcdb48dc749903598a546786a3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/93ddc1f96117bf468976afe93a077eda77de96bcdb48dc749903598a546786a3?s=96&d=mm&r=g","caption":"serkanadmin"},"sameAs":["https:\/\/serkanseker.com"],"url":"https:\/\/serkanseker.com\/tr\/author\/serkanadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/posts\/794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/comments?post=794"}],"version-history":[{"count":0,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/posts\/794\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/media\/156"}],"wp:attachment":[{"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/media?parent=794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/categories?post=794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/tags?post=794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}