Using Blazor server components without ending whitespace in wrapping container places the last component first
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
I am using a standard razor pages application and using Blazor Server rendering to it. There are lots of articles on how to do this. [This](https://www.syncfusion.com/faq/blazor/general/how-do-you-use-blazor-in-an-existing-asp-net-mvc-application) is just one.
If you render the same component (or different ones in the same wrapping container) without leaving a new line before the closing wrapping tag at the end like so:
``` c#
@(await Html.RenderComponentAsync(RenderMode.Server, new { Title = "Test 1" }))
@(await Html.RenderComponentAsync(RenderMode.Server, new { Title = "Test 2" }))
@(await Html.RenderComponentAsync(RenderMode.Server, new { Title = "Test 3" }))
```
It will render the components in a different order - placing the last one (Test 3) first:

### Expected Behavior
I would expect the components to be rendered as they are placed in the code like so:

### Steps To Reproduce
I am using a starter template for a razor pages app and just added my custom blazor component to it. All there is to do is to run the app, it would automatically open the Index page.
The changes are in the Index.cshml file.
[WebApplication1.zip](https://github.com/dotnet/aspnetcore/files/9469356/WebApplication1.zip)
### Exceptions (if any)
_No response_
### .NET Version
6.0
### Anything else?
A workaround would be to add a new line before the closing wrapping tag.
``` c#
@(await Html.RenderComponentAsync(RenderMode.Server, new { Title = "Test 1" }))
@(await Html.RenderComponentAsync(RenderMode.Server, new { Title = "Test 2" }))
@(await Html.RenderComponentAsync(RenderMode.Server, new { Title = "Test 3" }))
```
Contributor guide
Assessment
This issue has not been assessed yet.