-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed as not planned
Closed as not planned
Copy link
Labels
affected-fewThis issue impacts only small number of customersThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-prerenderingIssues related to prerendering blazor componentsIssues related to prerendering blazor componentsseverity-majorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Description
I have my own version of ComponentTagHelper
var componentRenderer = ViewContext.HttpContext.RequestServices.GetRequiredService<IComponentRenderer>();
var result = await componentRenderer.RenderComponentAsync(ViewContext, ComponentType, RenderMode, _parameters);
However Microsoft.AspNetCore.Mvc.ViewFeatures.IComponentRenderer
is not marked as public.
To work around this, I use reflection.
var type = Type.GetType("Microsoft.AspNetCore.Mvc.ViewFeatures.IComponentRenderer, Microsoft.AspNetCore.Mvc.ViewFeatures, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60");
var componentRenderer = ViewContext.HttpContext.RequestServices.GetRequiredService(type);
var method = type.GetMethod("RenderComponentAsync");
Parameters[nameof(CascadingAuthenticationStateComponent.ComponentType)] = ComponentType.AssemblyQualifiedName;
var result = await (Task<IHtmlContent>)method.Invoke(componentRenderer, new object[] { ViewContext, typeof(CascadingAuthenticationStateComponent), RenderMode, Parameters });
please make IComponentRenderer
public.
Metadata
Metadata
Assignees
Labels
affected-fewThis issue impacts only small number of customersThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-prerenderingIssues related to prerendering blazor componentsIssues related to prerendering blazor componentsseverity-majorThis label is used by an internal toolThis label is used by an internal tool