{"id":804,"date":"2020-10-09T08:55:46","date_gmt":"2020-10-09T08:55:46","guid":{"rendered":"https:\/\/serkanseker.com\/?p=804"},"modified":"2020-12-07T15:47:37","modified_gmt":"2020-12-07T15:47:37","slug":"asp-net-core-web-api-application-structure","status":"publish","type":"post","link":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/","title":{"rendered":"ASP.NET Core Web API Application Structure"},"content":{"rendered":"\n<p>Here you will learn the structure and importance of the Web API project created with <a href=\"https:\/\/dotnet.microsoft.com\/download\/dotnet-core\/3.1\" target=\"_blank\" rel=\"noreferrer noopener\">ASP.NET Core 3.1<\/a>.<\/p>\n\n\n\n<p>Before starting, I recommend you to review the article called <a href=\"https:\/\/serkanseker.com\/create-and-consume-asp-net-core-web-api\/\" target=\"_blank\" rel=\"noreferrer noopener\">Create And Consume ASP.NET Core Web API<\/a>, where I show you how to create a project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Project Structure<\/h2>\n\n\n\n<p>The following is a default project structure when you create an ASP.NET Core Web API project in Visual Studio.<\/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\">.csproj File Structure<\/h2>\n\n\n\n<p>The .csproj file contains settings such as .NET Frameworks, project files, NuGet packages. It does not create .csproj in ASP.NET Core 1.0, instead the project is managed with .xproj and project.json files.<\/p>\n\n\n\n<p>Right-click the project and select <strong>Edit Project File<\/strong> to access the .csproj file.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/serkanseker.com\/wp-content\/uploads\/2020\/10\/csproj-file.jpg\" alt=\".csproj file structure\" class=\"wp-image-806\"\/><figcaption>.csproj structure<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Dependencies <\/h2>\n\n\n\n<p>Dependencies includes all installed server-side <strong>NuGet packages<\/strong>, <strong>Analyzers <\/strong>and <strong>Frameworks<\/strong>. To add NuGet packages, right-click the project and select <strong>Manage NuGet Packages<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Properties <\/h2>\n\n\n\n<p>Properties contains the file <strong>launchSettings.json<\/strong>, which contains Visual Studio profiles of debug settings.<\/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\/launchSettings.json_.jpg\" alt=\"launchSettings.json structure\" class=\"wp-image-807\" width=\"870\" height=\"556\"\/><figcaption>launchSettings.json structure<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Program.cs<\/h2>\n\n\n\n<p>The Main method in the Program.cs file in the project is the starting point of the project. The most basic components needed by the application are connected to the WebHostBuilder object created here, and the application is run over this object.<\/p>\n\n\n\n<p>Startup class is the second method that runs after the main method. While the basic components are determined in the Main method, the middleware and service components needed in the next step will be determined in the class named Startup. The WebHostBuilder object determines this class with the UseStartup() method.<\/p>\n\n\n\n<p><\/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\/Program.cs_.jpg\" alt=\"Program.cs class \" class=\"wp-image-808\" width=\"753\" height=\"572\"\/><figcaption>Program.cs structure<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Startup.cs<\/h2>\n\n\n\n<p>There are two important methods in this class; <strong>Configure <\/strong>and <strong>ConfigureServices<\/strong>.<\/p>\n\n\n\n<p>Middleware components are determined in the <strong>Configure <\/strong>method. They structures that we can liken to HttpModules in ASP.NET. They are structures that take place in the application pipeline and run on every request-response.<\/p>\n\n\n\n<p>In the <strong>ConfigureServices<\/strong> method, service components are registered to the container object and are used in different parts of the application (for example, Controller classes).<\/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\/Startup.cs_.jpg\" alt=\"Startup.cs class\" class=\"wp-image-809\" width=\"961\" height=\"588\"\/><figcaption>Startup.cs structure<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this article, I tried to explain the structure of a project created with ASP.NET Core 3.1. The titles here should be discussed in detail.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Posts<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/serkanseker.com\/create-and-consume-asp-net-core-web-api\/\" target=\"_blank\" rel=\"noreferrer noopener\">Create And Consume ASP.NET Core Web API<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Here you will learn the structure and importance of the Web API project created with ASP.NET Core 3.1.<br \/>\nThe Main method in the Program.cs file in the project is the starting point of the project. The most basic components needed by the application are connected to the WebHostBuilder object created here, and the application is run over this object.<\/p>\n","protected":false},"author":1,"featured_media":193,"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],"class_list":["post-804","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net","tag-asp-net","tag-asp-net-core"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ASP.NET Core Web API Application Structure - 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=\"ASP.NET Core Web API Application Structure - Serkan Seker TR\" \/>\n<meta property=\"og:description\" content=\"Here you will learn the structure and importance of the Web API project created with ASP.NET Core 3.1. The Main method in the Program.cs file in the project is the starting point of the project. The most basic components needed by the application are connected to the WebHostBuilder object created here, and the application is run over this object.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/\" \/>\n<meta property=\"og:site_name\" content=\"Serkan Seker TR\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-09T08:55:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-07T15:47:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.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\/asp-net-core-web-api-application-structure\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/\"},\"author\":{\"name\":\"serkanadmin\",\"@id\":\"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5\"},\"headline\":\"ASP.NET Core Web API Application Structure\",\"datePublished\":\"2020-10-09T08:55:46+00:00\",\"dateModified\":\"2020-12-07T15:47:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/\"},\"wordCount\":381,\"commentCount\":1,\"image\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.jpg\",\"keywords\":[\"ASP.NET\",\"ASP.NET Core\"],\"articleSection\":[\"ASP.NET\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/\",\"url\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/\",\"name\":\"ASP.NET Core Web API Application Structure - Serkan Seker TR\",\"isPartOf\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.jpg\",\"datePublished\":\"2020-10-09T08:55:46+00:00\",\"dateModified\":\"2020-12-07T15:47:37+00:00\",\"author\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5\"},\"breadcrumb\":{\"@id\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#primaryimage\",\"url\":\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.jpg\",\"contentUrl\":\"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/serkanseker.com\/tr\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ASP.NET Core Web API Application Structure\"}]},{\"@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":"ASP.NET Core Web API Application Structure - 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":"ASP.NET Core Web API Application Structure - Serkan Seker TR","og_description":"Here you will learn the structure and importance of the Web API project created with ASP.NET Core 3.1. The Main method in the Program.cs file in the project is the starting point of the project. The most basic components needed by the application are connected to the WebHostBuilder object created here, and the application is run over this object.","og_url":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/","og_site_name":"Serkan Seker TR","article_published_time":"2020-10-09T08:55:46+00:00","article_modified_time":"2020-12-07T15:47:37+00:00","og_image":[{"url":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.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\/asp-net-core-web-api-application-structure\/#article","isPartOf":{"@id":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/"},"author":{"name":"serkanadmin","@id":"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5"},"headline":"ASP.NET Core Web API Application Structure","datePublished":"2020-10-09T08:55:46+00:00","dateModified":"2020-12-07T15:47:37+00:00","mainEntityOfPage":{"@id":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/"},"wordCount":381,"commentCount":1,"image":{"@id":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.jpg","keywords":["ASP.NET","ASP.NET Core"],"articleSection":["ASP.NET"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/","url":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/","name":"ASP.NET Core Web API Application Structure - Serkan Seker TR","isPartOf":{"@id":"https:\/\/serkanseker.com\/tr\/#website"},"primaryImageOfPage":{"@id":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#primaryimage"},"image":{"@id":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.jpg","datePublished":"2020-10-09T08:55:46+00:00","dateModified":"2020-12-07T15:47:37+00:00","author":{"@id":"https:\/\/serkanseker.com\/tr\/#\/schema\/person\/841fcc69b248e08e52c4190963caeaf5"},"breadcrumb":{"@id":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#primaryimage","url":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.jpg","contentUrl":"https:\/\/serkanseker.com\/tr\/wp-content\/uploads\/2020\/12\/ASP.NET-Core-Web-API-Application-Structure.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/serkanseker.com\/tr\/asp-net-core-web-api-application-structure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/serkanseker.com\/tr\/"},{"@type":"ListItem","position":2,"name":"ASP.NET Core Web API Application Structure"}]},{"@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\/804","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=804"}],"version-history":[{"count":0,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/posts\/804\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/media\/193"}],"wp:attachment":[{"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/media?parent=804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/categories?post=804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/serkanseker.com\/tr\/wp-json\/wp\/v2\/tags?post=804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}