From 8311dca46dfff109195bef4206cd5b13e0ecbb85 Mon Sep 17 00:00:00 2001 From: James Oliver Date: Fri, 3 Mar 2017 10:54:03 -0500 Subject: [PATCH 1/7] Added Note to add .UseIISIntegration The WebAPI project template did not include .UseIISIntegration() in my Program.cs Main(). However, Visual Studio was still defaulted to IIS Express. This would cause the app to display a blank browser that never loaded content. --- aspnetcore/tutorials/first-web-api.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aspnetcore/tutorials/first-web-api.md b/aspnetcore/tutorials/first-web-api.md index 9943556ba10f..b6785bb0006f 100644 --- a/aspnetcore/tutorials/first-web-api.md +++ b/aspnetcore/tutorials/first-web-api.md @@ -201,6 +201,11 @@ In contrast, the `GetById` method returns the more general `IActionResult` type, In Visual Studio, press CTRL+F5 to launch the app. Visual Studio launches a browser and navigates to `http://localhost:port/api/values`, where *port* is a randomly chosen port number. If you're using Chrome, Edge or Firefox, the data will be displayed. If you're using IE, IE will prompt to you open or save the *values.json* file. Navigate to the `Todo` controller we just created `http://localhost:port/api/todo`. +> [!NOTE] +> If you are attempting to use IIS Express (default) and the application does not display in your browser, check to make sure that your Main function in Program.cs includes ```csharp .UseIISIntegration()``` + +[!code-csharp[Main](first-web-api/sample/src/TodoApi/Program.cs)] + ## Implement the other CRUD operations We'll add `Create`, `Update`, and `Delete` methods to the controller. These are variations on a theme, so I'll just show the code and highlight the main differences. Build the project after adding or changing code. From 2aecd686fbaf8771768c2b960b89cb86e077cb85 Mon Sep 17 00:00:00 2001 From: James Oliver Date: Fri, 3 Mar 2017 12:33:31 -0500 Subject: [PATCH 2/7] Updated with recommended changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use contractions ("you're" over "you are" and "doesn't" over "does not") Personally, I'd go with "confirm" over "check to make sure" just because it conveys the same info faster. 🏃 Say "Main method" and use a single backtick on each side of "Main" ... use `Main` Filenames should be in italics, so put one asterisk (*) around "Program.cs" ... use *Program.cs* Inline code should have a single backtick and drop the "csharp" ... so it will just be `.UseIISIntegration()` Since this points directly at a code sample, place a colon at the end of the line. --- aspnetcore/tutorials/first-web-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/tutorials/first-web-api.md b/aspnetcore/tutorials/first-web-api.md index b6785bb0006f..425fcf911503 100644 --- a/aspnetcore/tutorials/first-web-api.md +++ b/aspnetcore/tutorials/first-web-api.md @@ -202,7 +202,7 @@ In contrast, the `GetById` method returns the more general `IActionResult` type, In Visual Studio, press CTRL+F5 to launch the app. Visual Studio launches a browser and navigates to `http://localhost:port/api/values`, where *port* is a randomly chosen port number. If you're using Chrome, Edge or Firefox, the data will be displayed. If you're using IE, IE will prompt to you open or save the *values.json* file. Navigate to the `Todo` controller we just created `http://localhost:port/api/todo`. > [!NOTE] -> If you are attempting to use IIS Express (default) and the application does not display in your browser, check to make sure that your Main function in Program.cs includes ```csharp .UseIISIntegration()``` +> If you're attempting to use IIS Express (default) and the application does not display in your browser, confirm that your `Main` method in *Program.cs* includes `.UseIISIntegration()`: [!code-csharp[Main](first-web-api/sample/src/TodoApi/Program.cs)] From b84f1927c531bcf6cc5b20d149a020e71ca5d10c Mon Sep 17 00:00:00 2001 From: James Oliver Date: Fri, 3 Mar 2017 12:37:53 -0500 Subject: [PATCH 3/7] Added snippet for docs snippet_program_main --- .../tutorials/first-web-api/sample/src/TodoApi/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aspnetcore/tutorials/first-web-api/sample/src/TodoApi/Program.cs b/aspnetcore/tutorials/first-web-api/sample/src/TodoApi/Program.cs index 245b684f9005..85d85acc0bca 100644 --- a/aspnetcore/tutorials/first-web-api/sample/src/TodoApi/Program.cs +++ b/aspnetcore/tutorials/first-web-api/sample/src/TodoApi/Program.cs @@ -10,6 +10,7 @@ namespace TodoApi { public class Program { + #region snippet_program_main public static void Main(string[] args) { var host = new WebHostBuilder() @@ -21,5 +22,6 @@ public static void Main(string[] args) host.Run(); } + #endregion } } From ea93790ff742d3d7ea904bd18aaacc3d0908a532 Mon Sep 17 00:00:00 2001 From: James Oliver Date: Fri, 3 Mar 2017 12:41:24 -0500 Subject: [PATCH 4/7] Updating with recommended syntax Using function specific snipped Add Highlight to specific line --- aspnetcore/tutorials/first-web-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/tutorials/first-web-api.md b/aspnetcore/tutorials/first-web-api.md index 425fcf911503..74afb8199acc 100644 --- a/aspnetcore/tutorials/first-web-api.md +++ b/aspnetcore/tutorials/first-web-api.md @@ -204,7 +204,7 @@ In Visual Studio, press CTRL+F5 to launch the app. Visual Studio launches a brow > [!NOTE] > If you're attempting to use IIS Express (default) and the application does not display in your browser, confirm that your `Main` method in *Program.cs* includes `.UseIISIntegration()`: -[!code-csharp[Main](first-web-api/sample/src/TodoApi/Program.cs)] +> [!code-csharp[Main](first-web-api/sample/src/TodoApi/Program.cs?name=snippet_program_main&highlight=6)] ## Implement the other CRUD operations From de66930e2ba3c3ca8540766166f02d29637fcf0c Mon Sep 17 00:00:00 2001 From: Rick Anderson Date: Fri, 3 Mar 2017 10:24:41 -1000 Subject: [PATCH 5/7] shorten --- aspnetcore/tutorials/first-web-api.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/aspnetcore/tutorials/first-web-api.md b/aspnetcore/tutorials/first-web-api.md index 74afb8199acc..b1db8315857c 100644 --- a/aspnetcore/tutorials/first-web-api.md +++ b/aspnetcore/tutorials/first-web-api.md @@ -201,10 +201,7 @@ In contrast, the `GetById` method returns the more general `IActionResult` type, In Visual Studio, press CTRL+F5 to launch the app. Visual Studio launches a browser and navigates to `http://localhost:port/api/values`, where *port* is a randomly chosen port number. If you're using Chrome, Edge or Firefox, the data will be displayed. If you're using IE, IE will prompt to you open or save the *values.json* file. Navigate to the `Todo` controller we just created `http://localhost:port/api/todo`. -> [!NOTE] -> If you're attempting to use IIS Express (default) and the application does not display in your browser, confirm that your `Main` method in *Program.cs* includes `.UseIISIntegration()`: - -> [!code-csharp[Main](first-web-api/sample/src/TodoApi/Program.cs?name=snippet_program_main&highlight=6)] +Note: If the browser doesn't display data, verify that that the `Main` method in *Program.cs* includes `UseIISIntegration`. If you selected **Enable Docker Support** when you created the web app, `UseIISIntegration` will not be in added to `Main`. ## Implement the other CRUD operations From bda0a48ee435ddb0fc850a3720f61bbde859b146 Mon Sep 17 00:00:00 2001 From: Rick Anderson Date: Fri, 3 Mar 2017 10:29:33 -1000 Subject: [PATCH 6/7] typo --- aspnetcore/tutorials/first-web-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/tutorials/first-web-api.md b/aspnetcore/tutorials/first-web-api.md index b1db8315857c..b3ae8a68ad47 100644 --- a/aspnetcore/tutorials/first-web-api.md +++ b/aspnetcore/tutorials/first-web-api.md @@ -201,7 +201,7 @@ In contrast, the `GetById` method returns the more general `IActionResult` type, In Visual Studio, press CTRL+F5 to launch the app. Visual Studio launches a browser and navigates to `http://localhost:port/api/values`, where *port* is a randomly chosen port number. If you're using Chrome, Edge or Firefox, the data will be displayed. If you're using IE, IE will prompt to you open or save the *values.json* file. Navigate to the `Todo` controller we just created `http://localhost:port/api/todo`. -Note: If the browser doesn't display data, verify that that the `Main` method in *Program.cs* includes `UseIISIntegration`. If you selected **Enable Docker Support** when you created the web app, `UseIISIntegration` will not be in added to `Main`. +Note: If the browser doesn't display data, verify that that the `Main` method in *Program.cs* includes `UseIISIntegration`. If you selected **Enable Docker Support** when you created the web app, `UseIISIntegration` will not be added to `Main`. ## Implement the other CRUD operations From 8e1e7698a5949f61c2a0f3d4d5fc953fc22eb2cf Mon Sep 17 00:00:00 2001 From: Rick Anderson Date: Fri, 3 Mar 2017 14:07:32 -1000 Subject: [PATCH 7/7] warn about docker at the begging --- aspnetcore/tutorials/first-web-api.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/aspnetcore/tutorials/first-web-api.md b/aspnetcore/tutorials/first-web-api.md index b3ae8a68ad47..107d317454d0 100644 --- a/aspnetcore/tutorials/first-web-api.md +++ b/aspnetcore/tutorials/first-web-api.md @@ -22,8 +22,7 @@ In this tutorial, you’ll build a simple web API for managing a list of "to-do" ASP.NET Core has built-in support for MVC building Web APIs. Unifying the two frameworks makes it simpler to build apps that include both UI (HTML) and APIs, because now they share the same code base and pipeline. -> [!NOTE] -> If you are porting an existing Web API app to ASP.NET Core, see [Migrating from ASP.NET Web API](../migration/webapi.md) +Note: If you are porting an existing Web API app to ASP.NET Core, see [Migrating from ASP.NET Web API](xref:migration/webapi) ## Overview @@ -57,11 +56,11 @@ The following diagram shows the basic design of the app. Start Visual Studio. From the **File** menu, select **New** > **Project**. -Select the **ASP.NET Core Web Application (.NET Core)** project template. Name the project `TodoApi`, clear **Host in the cloud**, and tap **OK**. +Select the **ASP.NET Core Web Application (.NET Core)** project template. Name the project `TodoApi`, and tap **OK**. ![New project dialog](first-web-api/_static/new-project.png) -In the **New ASP.NET Core Web Application (.NET Core) - TodoApi** dialog, select the **Web API** template. Tap **OK**. +In the **New ASP.NET Core Web Application (.NET Core) - TodoApi** dialog, select the **Web API** template. Do **not** check **Enable Docker Support**. Tap **OK**. ![New ASP.NET Web Application dialog with Web API project template selected from ASP.NET Core Templates](first-web-api/_static/web-api-project.png) @@ -201,8 +200,6 @@ In contrast, the `GetById` method returns the more general `IActionResult` type, In Visual Studio, press CTRL+F5 to launch the app. Visual Studio launches a browser and navigates to `http://localhost:port/api/values`, where *port* is a randomly chosen port number. If you're using Chrome, Edge or Firefox, the data will be displayed. If you're using IE, IE will prompt to you open or save the *values.json* file. Navigate to the `Todo` controller we just created `http://localhost:port/api/todo`. -Note: If the browser doesn't display data, verify that that the `Main` method in *Program.cs* includes `UseIISIntegration`. If you selected **Enable Docker Support** when you created the web app, `UseIISIntegration` will not be added to `Main`. - ## Implement the other CRUD operations We'll add `Create`, `Update`, and `Delete` methods to the controller. These are variations on a theme, so I'll just show the code and highlight the main differences. Build the project after adding or changing code.