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

Blazor components do not work in partial views. #20332

Closed
wocar opened this issue Mar 30, 2020 · 4 comments
Closed

Blazor components do not work in partial views. #20332

wocar opened this issue Mar 30, 2020 · 4 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Status: No Recent Activity

Comments

@wocar
Copy link

wocar commented Mar 30, 2020

Describe the bug

Blazor components do not work in partial views.

To Reproduce

I have Index.cshtml that Invokes a partial view called _details.cshtml
Within that partial view I'm trying to invoke Details.razon Razor component like this:

@(await Html.RenderComponentAsync<Details>(RenderMode.ServerPrerendered))

Events don't get fired but content does get rendered.
If I use

@(await Html.RenderComponentAsync<Details>(RenderMode.Server))

The content doesn't even get rendered. On the other side, if I use either of the above in the Index.cshtml the component works perfectly.

Here is the Details component code

@using System.Net.Http
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop

<h3>Event Binding</h3> <br /> <br />
<button @onclick=@ButtonClicked>Event Binding Example</button>  <br /> <br />
<button @onclick=@(() => Message = "Inline:Button Clicked")>Inline Event Binding</button> <br /> <br />
<p>Message: @Message</p>

@functions {
    private string Message { get; set; } = "";
    void ButtonClicked()
    {
        Message = "Button Clicked";
    }
}

Any clues? Is this scenario supported? Thank you.

Further technical details

  • ASP.NET Core version: NET CORE 3.1
.NET Core SDK (reflecting any global.json):
 Version:   3.1.101
 Commit:    b377529961

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.1.101/

Host (useful for support):
  Version: 3.1.1
  Commit:  a1388f194c

.NET Core SDKs installed:
  2.1.4 [/usr/local/share/dotnet/sdk]
  2.1.302 [/usr/local/share/dotnet/sdk]
  2.1.505 [/usr/local/share/dotnet/sdk]
  2.2.106 [/usr/local/share/dotnet/sdk]
  3.0.100 [/usr/local/share/dotnet/sdk]
  3.1.100 [/usr/local/share/dotnet/sdk]
  3.1.101 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

  • Rider 2019.3
@javiercn
Copy link
Member

@wocar thanks for contacting us.

We'll take a look at this issue and get back to you.

@pranavkm we had issues in this area in the past, do you remember?

@javiercn javiercn added this to the Next sprint planning milestone Mar 31, 2020
@wocar
Copy link
Author

wocar commented Apr 3, 2020

is there anything i can do to help? thank you

@pranavkm
Copy link
Contributor

pranavkm commented May 6, 2020

@wocar I tried this out and I am unable to see any issues with this. Can you share a minimal repro app for us to investigate this further?

@pranavkm pranavkm modified the milestone: 5.0.0-preview4 May 6, 2020
@pranavkm pranavkm added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label May 6, 2020
@ghost
Copy link

ghost commented May 10, 2020

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed May 14, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jun 13, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Status: No Recent Activity
Projects
None yet
Development

No branches or pull requests

4 participants