{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/training-tutorials/pulls/comments/70846347","id":70846347,"diff_hunk":"@@ -3,13 +3,76 @@ by [Steve Smith](http://deviq.com/me/steve-smith)\n \n See the [Issue](https://github.com/dotnet/training-tutorials/issues/48) to claim this lesson and/or view what should be included in it.\n \n-## First Header\n+## Program.cs\n \n-Start the lesson here.\n+In the [first lesson](your-first.md), you saw how to take a console application and convert it into an ASP.NET Core web app. Part of that process involved updating the ``Main`` method in *Program.cs* to configure and run a *host*. ASP.NET apps must run within a host, and this host is typically configured in a ``Main`` method. Once configured, you won't typically need to update this file very often going forward. A very simple, minimal example would be:\n \n-...\n+```c#\n+using System;\n+using Microsoft.AspNetCore.Hosting;\n \n+namespace ConsoleApplication\n+{\n+    public class Program\n+    {\n+        public static void Main(string[] args)\n+        {\n+            var host = new WebHostBuilder()\n+                .UseKestrel()\n+                .UseStartup<Startup>()\n+                .Build();\n+\n+            host.Run();\n+        }\n+    }\n+}\n+```\n+\n+Note that the above class references the ``Startup`` type, which is where you configure your individual app.\n+\n+## Startup.cs\n+\n+The *Startup.cs* file contains the application's ``Startup`` class. This class must include certain methods that will be called by the host (that you just saw was configured in *Program.cs*). Specifically, the class must define a ``Configure`` method. It can optionally include a ``ConfigureServices`` method and/or a constructor as well.\n+\n+### Configure\n+\n+The ``Configure`` method is used to configure how your app will handle requests. This is sometimes referred to as the app's *request pipeline*, and involves configuring one or more pieces of *middleware*. At its most basic, an ASP.NET Core app can configure a single handler that will respond to every request, like this one:\n+\n+```c#\n+using System;\n+using Microsoft.AspNetCore.Builder;\n+using Microsoft.AspNetCore.Hosting;\n+using Microsoft.AspNetCore.Http;\n+\n+namespace ConsoleApplication\n+{\n+    public class Startup\n+    {\n+        public void Configure(IApplicationBuilder app)\n+        {\n+            app.Run(context =>\n+            {\n+                return context.Response.WriteAsync(\"Hello from ASP.NET Core!\");\n+            });\n+        }\n+    }\n+}\n+```\n+\n+The ``app.Run`` method configures middleware, which you'll learn more about in the next lesson. In addition to configuring your app's request pipeline, the ``Configure`` method is also used to (surprise!) configure other aspects of the app. It's here that you'll add support for diagnostics, logging, error handling, routing, and frameworks like MVC. These packages often have helper methods that follow a naming pattern of ``Use[Package]``, which is used to configure them within the ``Configure`` method. For example, configuring MVC is done with the ``app.UseMvc();`` statement. You'll see examples of these packages in later lessons in this tutorial. \n+\n+### ConfigureServices\n+\n+The ``ConfigureServices`` method in the ``Startup`` class is optional. You use it to populate the services *container* used by ASP.NET Core. This container provides requested services to objects within your app through a process called [dependency injection](http://deviq.com/dependency-injection/). The container is represented by the ``IServiceCollection`` parameter that is passed into the ``ConfigureServices`` method. ASP.NET Core provides and requests many services itself, and uses the same infrastructure you will use in your app. Many built-in as well as third-party features require certain services to work properly, and you'll often see a particular package (for instance, MVC) adding services in ``ConfigureServices`` and also being configured in ``Configure``.\n+\n+Some packages will require many different services. Rather than requiring many statements to register each service individually, helper methods are added. By convention, these helper methods follow a naming pattern of ``Add[Package]``. So, for example, to add the services needed by MVC, you would add the statement ``services.AddMvc();`` to ``ConfigureServices``.\n+\n+## Other files\n+\n+Your ASP.NET Core app also requires a project file. However, most of the time you won't need to work with this file directly, and in any case its structure will be changing before .NET Core's tooling (which includes the command line interface as well as editors like VS Code and Visual Studio) are finalized. For now, you'll notice a *project.json* and probably a *project.json.lock* file in your application folder.\n+\n+To include support for certain features in your ASP.NET Core app, you may need to add additional packages to your app. This is currently done by modifying the *dependencies* section of the *project.json* file. When this is required, the tutorial instructions will walk you through what's required.\n \n ## Next Steps\n \n-Give the reader some additional exercises/tasks they can perform to try out what they've just learned.\n\\ No newline at end of file\n+In the next lesson, you'll learn how to customize responses from your ASP.NET Core app based on the client's request.","path":"content/asp.net/getting-started/files.md","position":81,"original_position":81,"commit_id":"10261d89351ad3bd8a07d68ea30f08024fdb3496","original_commit_id":"10261d89351ad3bd8a07d68ea30f08024fdb3496","user":{"login":"ardalis","id":782127,"avatar_url":"https://avatars.githubusercontent.com/u/782127?v=3","gravatar_id":"","url":"https://api.github.com/users/ardalis","html_url":"https://github.com/ardalis","followers_url":"https://api.github.com/users/ardalis/followers","following_url":"https://api.github.com/users/ardalis/following{/other_user}","gists_url":"https://api.github.com/users/ardalis/gists{/gist_id}","starred_url":"https://api.github.com/users/ardalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardalis/subscriptions","organizations_url":"https://api.github.com/users/ardalis/orgs","repos_url":"https://api.github.com/users/ardalis/repos","events_url":"https://api.github.com/users/ardalis/events{/privacy}","received_events_url":"https://api.github.com/users/ardalis/received_events","type":"User","site_admin":false},"body":"Fair point. Added a bit.","created_at":"2016-07-14T17:23:24Z","updated_at":"2016-07-14T17:23:24Z","html_url":"https://github.com/dotnet/training-tutorials/pull/153#discussion_r70846347","pull_request_url":"https://api.github.com/repos/dotnet/training-tutorials/pulls/153","_links":{"self":{"href":"https://api.github.com/repos/dotnet/training-tutorials/pulls/comments/70846347"},"html":{"href":"https://github.com/dotnet/training-tutorials/pull/153#discussion_r70846347"},"pull_request":{"href":"https://api.github.com/repos/dotnet/training-tutorials/pulls/153"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/training-tutorials/pulls/153","id":76022942,"html_url":"https://github.com/dotnet/training-tutorials/pull/153","diff_url":"https://github.com/dotnet/training-tutorials/pull/153.diff","patch_url":"https://github.com/dotnet/training-tutorials/pull/153.patch","issue_url":"https://api.github.com/repos/dotnet/training-tutorials/issues/153","number":153,"state":"open","locked":false,"title":"ASPNET Core Files","user":{"login":"ardalis","id":782127,"avatar_url":"https://avatars.githubusercontent.com/u/782127?v=3","gravatar_id":"","url":"https://api.github.com/users/ardalis","html_url":"https://github.com/ardalis","followers_url":"https://api.github.com/users/ardalis/followers","following_url":"https://api.github.com/users/ardalis/following{/other_user}","gists_url":"https://api.github.com/users/ardalis/gists{/gist_id}","starred_url":"https://api.github.com/users/ardalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardalis/subscriptions","organizations_url":"https://api.github.com/users/ardalis/orgs","repos_url":"https://api.github.com/users/ardalis/repos","events_url":"https://api.github.com/users/ardalis/events{/privacy}","received_events_url":"https://api.github.com/users/ardalis/received_events","type":"User","site_admin":false},"body":"Fixes #48 ","created_at":"2016-07-01T18:57:52Z","updated_at":"2016-07-14T17:23:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9fa6e21b634211f318bb92e28236a80e466955ed","assignee":{"login":"ardalis","id":782127,"avatar_url":"https://avatars.githubusercontent.com/u/782127?v=3","gravatar_id":"","url":"https://api.github.com/users/ardalis","html_url":"https://github.com/ardalis","followers_url":"https://api.github.com/users/ardalis/followers","following_url":"https://api.github.com/users/ardalis/following{/other_user}","gists_url":"https://api.github.com/users/ardalis/gists{/gist_id}","starred_url":"https://api.github.com/users/ardalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardalis/subscriptions","organizations_url":"https://api.github.com/users/ardalis/orgs","repos_url":"https://api.github.com/users/ardalis/repos","events_url":"https://api.github.com/users/ardalis/events{/privacy}","received_events_url":"https://api.github.com/users/ardalis/received_events","type":"User","site_admin":false},"assignees":[{"login":"ardalis","id":782127,"avatar_url":"https://avatars.githubusercontent.com/u/782127?v=3","gravatar_id":"","url":"https://api.github.com/users/ardalis","html_url":"https://github.com/ardalis","followers_url":"https://api.github.com/users/ardalis/followers","following_url":"https://api.github.com/users/ardalis/following{/other_user}","gists_url":"https://api.github.com/users/ardalis/gists{/gist_id}","starred_url":"https://api.github.com/users/ardalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardalis/subscriptions","organizations_url":"https://api.github.com/users/ardalis/orgs","repos_url":"https://api.github.com/users/ardalis/repos","events_url":"https://api.github.com/users/ardalis/events{/privacy}","received_events_url":"https://api.github.com/users/ardalis/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/training-tutorials/pulls/153/commits","review_comments_url":"https://api.github.com/repos/dotnet/training-tutorials/pulls/153/comments","review_comment_url":"https://api.github.com/repos/dotnet/training-tutorials/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/training-tutorials/issues/153/comments","statuses_url":"https://api.github.com/repos/dotnet/training-tutorials/statuses/10261d89351ad3bd8a07d68ea30f08024fdb3496","head":{"label":"dotnet:ardalis/aspnet-files","ref":"ardalis/aspnet-files","sha":"10261d89351ad3bd8a07d68ea30f08024fdb3496","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":59598094,"name":"training-tutorials","full_name":"dotnet/training-tutorials","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/training-tutorials","description":"Getting started tutorials for C# and ASP.NET","fork":false,"url":"https://api.github.com/repos/dotnet/training-tutorials","forks_url":"https://api.github.com/repos/dotnet/training-tutorials/forks","keys_url":"https://api.github.com/repos/dotnet/training-tutorials/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/training-tutorials/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/training-tutorials/teams","hooks_url":"https://api.github.com/repos/dotnet/training-tutorials/hooks","issue_events_url":"https://api.github.com/repos/dotnet/training-tutorials/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/training-tutorials/events","assignees_url":"https://api.github.com/repos/dotnet/training-tutorials/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/training-tutorials/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/training-tutorials/tags","blobs_url":"https://api.github.com/repos/dotnet/training-tutorials/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/training-tutorials/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/training-tutorials/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/training-tutorials/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/training-tutorials/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/training-tutorials/languages","stargazers_url":"https://api.github.com/repos/dotnet/training-tutorials/stargazers","contributors_url":"https://api.github.com/repos/dotnet/training-tutorials/contributors","subscribers_url":"https://api.github.com/repos/dotnet/training-tutorials/subscribers","subscription_url":"https://api.github.com/repos/dotnet/training-tutorials/subscription","commits_url":"https://api.github.com/repos/dotnet/training-tutorials/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/training-tutorials/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/training-tutorials/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/training-tutorials/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/training-tutorials/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/training-tutorials/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/training-tutorials/merges","archive_url":"https://api.github.com/repos/dotnet/training-tutorials/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/training-tutorials/downloads","issues_url":"https://api.github.com/repos/dotnet/training-tutorials/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/training-tutorials/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/training-tutorials/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/training-tutorials/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/training-tutorials/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/training-tutorials/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/training-tutorials/deployments","created_at":"2016-05-24T18:25:52Z","updated_at":"2016-07-13T15:22:49Z","pushed_at":"2016-07-07T01:25:09Z","git_url":"git://github.com/dotnet/training-tutorials.git","ssh_url":"git@github.com:dotnet/training-tutorials.git","clone_url":"https://github.com/dotnet/training-tutorials.git","svn_url":"https://github.com/dotnet/training-tutorials","homepage":"http://dot.net/","size":576,"stargazers_count":14,"watchers_count":14,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":25,"forks":7,"open_issues":25,"watchers":14,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"06e3e0db067bcb6b818fda48424363b4ac45e842","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":59598094,"name":"training-tutorials","full_name":"dotnet/training-tutorials","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/training-tutorials","description":"Getting started tutorials for C# and ASP.NET","fork":false,"url":"https://api.github.com/repos/dotnet/training-tutorials","forks_url":"https://api.github.com/repos/dotnet/training-tutorials/forks","keys_url":"https://api.github.com/repos/dotnet/training-tutorials/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/training-tutorials/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/training-tutorials/teams","hooks_url":"https://api.github.com/repos/dotnet/training-tutorials/hooks","issue_events_url":"https://api.github.com/repos/dotnet/training-tutorials/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/training-tutorials/events","assignees_url":"https://api.github.com/repos/dotnet/training-tutorials/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/training-tutorials/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/training-tutorials/tags","blobs_url":"https://api.github.com/repos/dotnet/training-tutorials/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/training-tutorials/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/training-tutorials/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/training-tutorials/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/training-tutorials/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/training-tutorials/languages","stargazers_url":"https://api.github.com/repos/dotnet/training-tutorials/stargazers","contributors_url":"https://api.github.com/repos/dotnet/training-tutorials/contributors","subscribers_url":"https://api.github.com/repos/dotnet/training-tutorials/subscribers","subscription_url":"https://api.github.com/repos/dotnet/training-tutorials/subscription","commits_url":"https://api.github.com/repos/dotnet/training-tutorials/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/training-tutorials/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/training-tutorials/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/training-tutorials/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/training-tutorials/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/training-tutorials/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/training-tutorials/merges","archive_url":"https://api.github.com/repos/dotnet/training-tutorials/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/training-tutorials/downloads","issues_url":"https://api.github.com/repos/dotnet/training-tutorials/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/training-tutorials/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/training-tutorials/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/training-tutorials/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/training-tutorials/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/training-tutorials/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/training-tutorials/deployments","created_at":"2016-05-24T18:25:52Z","updated_at":"2016-07-13T15:22:49Z","pushed_at":"2016-07-07T01:25:09Z","git_url":"git://github.com/dotnet/training-tutorials.git","ssh_url":"git@github.com:dotnet/training-tutorials.git","clone_url":"https://github.com/dotnet/training-tutorials.git","svn_url":"https://github.com/dotnet/training-tutorials","homepage":"http://dot.net/","size":576,"stargazers_count":14,"watchers_count":14,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":25,"forks":7,"open_issues":25,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/training-tutorials/pulls/153"},"html":{"href":"https://github.com/dotnet/training-tutorials/pull/153"},"issue":{"href":"https://api.github.com/repos/dotnet/training-tutorials/issues/153"},"comments":{"href":"https://api.github.com/repos/dotnet/training-tutorials/issues/153/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/training-tutorials/pulls/153/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/training-tutorials/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/training-tutorials/pulls/153/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/training-tutorials/statuses/10261d89351ad3bd8a07d68ea30f08024fdb3496"}}}}
{"actor":{"display_login":"ardalis"}}