Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RazorComponentResult<T> doesn't render either the Blazor or MVC Layout #31393

Closed
nfplee opened this issue Jan 9, 2024 · 5 comments · Fixed by #31425
Closed

RazorComponentResult<T> doesn't render either the Blazor or MVC Layout #31393

nfplee opened this issue Jan 9, 2024 · 5 comments · Fixed by #31425
Assignees
Labels
8.0 .NET 8 Blazor doc-enhancement Pri2 Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@nfplee
Copy link

nfplee commented Jan 9, 2024

Description

The section Return a RazorComponentResult from an MVC controller action suggests that a Layout will be applied to the Razor component, but I can't get it to work. It simply renders the content of Welcome.razor.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/components/integration?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/components/integration.md

Document ID

d7e39bbc-cd54-92aa-4997-f9dd39dd6ef3

Article author

@guardrex

Copy link
Contributor

github-actions bot commented Jan 9, 2024

🎉🥳 Happy New Year! 💃🕺

A green dinosaur 🦖 will be along shortly to assist. Stand-by ........

@guardrex
Copy link
Collaborator

guardrex commented Jan 9, 2024

Hello @nfplee ... Did you try applying a layout directly to the component file. For example something like ...

@using BlazorSample.Components.Layout
@layout MainLayout

suggests that a Layout will be applied

It doesn't address it, but I don't think we can describe everything that a dev might need to do for all of the different features that might work. I'm not even 100% sure really if the code I just suggested will work or 💥.

@nfplee
Copy link
Author

nfplee commented Jan 9, 2024

Thanks, I did try that and it then wrapped the component in the content from the MainLayout component but it did not include the content from the App.razor component (the html, head and body tags).

@guardrex
Copy link
Collaborator

guardrex commented Jan 9, 2024

it did not include the content from the App.razor component (the html, head and body tags).

... not too surprising based on my guess at how they set this feature up. I think the document here will need a little wording to say that only the component is rendered and that every bit of required additional markup (layouts and root component HTML) must also be provided.

I'll schedule this for work, and I'll probably ask Mackinnon on the product unit to look over my remarks before publication. Thanks for the issue. Leave this open, as it will close automatically later when the PR merges.

@nfplee
Copy link
Author

nfplee commented Jan 9, 2024

Thanks, it makes sense it would work this way. I hadn't questioned it until I read this article and figured there might be some magic I might've misunderstood.

@guardrex guardrex moved this from 8.0 to In progress in Blazor.Docs Jan 11, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Blazor.Docs Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.0 .NET 8 Blazor doc-enhancement Pri2 Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants