Added Note to add .UseIISIntegration()#2878
Conversation
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.
|
This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request. |
guardrex
left a comment
There was a problem hiding this comment.
Thanks for providing this. A few minor nits, and you should use a snippet and a highlight with the sample code. Let me know if you have any questions.
| 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()``` |
There was a problem hiding this comment.
Minor nits:
- 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.
| > [!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)] |
There was a problem hiding this comment.
Let's close this down just to the Main method and highlight the row, so modify the Program.cs file in the sample and place a "snippet1" around the Main method. Look at the following example from the ToDoController. The snippets are created using #region snippet_name and #endregion: https://github.com/aspnet/Docs/blob/master/aspnetcore/tutorials/first-web-api/sample/src/TodoApi/Controllers/TodoController.cs#L17-L34
... then refer to the snippet and highlight the line like I show below. I'm using "snippet1" here, but you can name it something more explicit if you like. The highlight counting starts with the first line in the snippet, so the .UseIISIntegration() line should be line 6.
Final note: To get the snippet into the NOTE, I think you'll need to get a > in front of it. In the contribution guidelines there's a section on how to build the docs locally in DocFX so that you can see the rendered snippet in the browser to confirm that things like this are correct. https://github.com/aspnet/Docs/blob/master/CONTRIBUTING.md#test-your-changes-with-docfx
> [!code-csharp[Main](first-web-api/sample/src/TodoApi/Program.cs?name=snippet1&highlight=6)]
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.
snippet_program_main
Using function specific snipped Add Highlight to specific line
|
@jolivr Thanks ... excellent work! @Rick-Anderson LGTM if placing the code inside the NOTE with |
|
@jolivr thanks for your consideration. There are endless reasons why the app might not behave as expected and we can't provide a note for each. This is our most popular tutorial and I've never seen this complaint before. If you follow the instructions you'd have to remove that call. |
|
@jolivr a good place to add this note is in a LiveFyre comment where you added your comment. If you think more than a few people will hit it you could even put it on SO |
|
@Rick-Anderson I was using VS 2017 and as it turns out, if you click "Add Docker Support" which I had done inadvertently, it does not add .UseIISIntegration(). |
|
@jolivr, It will cover your contributions to all Microsoft-managed open source projects. |
|
@jolivr, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
|
Lets keep the note as short as possible. I don't think many folks will hit this. To repro your problem you need to:
I wouldn't expect IIS Express to work with a docker project. |
|
@jolivr We need to update this for VS2017. I added warning up front. |
|
@jolivr Thanks for pointing this out. I'm going to update this document with new screen shots and I'll add a docker warning. |
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.