diff --git a/src/Components/test/E2ETest/ServerExecutionTests/ComponentWithParametersTest.cs b/src/Components/test/E2ETest/ServerExecutionTests/ComponentWithParametersTest.cs
index 87ed133449..1aefbe2b8e 100644
--- a/src/Components/test/E2ETest/ServerExecutionTests/ComponentWithParametersTest.cs
+++ b/src/Components/test/E2ETest/ServerExecutionTests/ComponentWithParametersTest.cs
@@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests
}
[Fact]
- public void PassingParametersToComponentsWorks()
+ public void PassingParametersToComponentsFromThePageWorks()
{
Navigate("/prerendered/componentwithparameters?QueryValue=testQueryValue");
diff --git a/src/Components/test/testassets/TestServer/Pages/MultipleComponents.cshtml b/src/Components/test/testassets/TestServer/Pages/MultipleComponents.cshtml
index 47c7677829..c387700129 100644
--- a/src/Components/test/testassets/TestServer/Pages/MultipleComponents.cshtml
+++ b/src/Components/test/testassets/TestServer/Pages/MultipleComponents.cshtml
@@ -10,8 +10,8 @@
-
-
+ @(await Html.RenderComponentAsync
(RenderMode.ServerPrerendered))
+ @(await Html.RenderComponentAsync(RenderMode.Server))
diff --git a/src/Mvc/Mvc.ViewFeatures/ref/Microsoft.AspNetCore.Mvc.ViewFeatures.netcoreapp.cs b/src/Mvc/Mvc.ViewFeatures/ref/Microsoft.AspNetCore.Mvc.ViewFeatures.netcoreapp.cs
index 9c94c22443..dfbd0dec1b 100644
--- a/src/Mvc/Mvc.ViewFeatures/ref/Microsoft.AspNetCore.Mvc.ViewFeatures.netcoreapp.cs
+++ b/src/Mvc/Mvc.ViewFeatures/ref/Microsoft.AspNetCore.Mvc.ViewFeatures.netcoreapp.cs
@@ -324,6 +324,7 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
}
public static partial class HtmlHelperComponentExtensions
{
+ public static System.Threading.Tasks.Task
RenderComponentAsync(this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, System.Type componentType, Microsoft.AspNetCore.Mvc.Rendering.RenderMode renderMode, object parameters) { throw null; }
public static System.Threading.Tasks.Task RenderComponentAsync(this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, Microsoft.AspNetCore.Mvc.Rendering.RenderMode renderMode) where TComponent : Microsoft.AspNetCore.Components.IComponent { throw null; }
public static System.Threading.Tasks.Task RenderComponentAsync(this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, Microsoft.AspNetCore.Mvc.Rendering.RenderMode renderMode, object parameters) where TComponent : Microsoft.AspNetCore.Components.IComponent { throw null; }
}
diff --git a/src/Mvc/Mvc.ViewFeatures/src/Rendering/HtmlHelperComponentExtensions.cs b/src/Mvc/Mvc.ViewFeatures/src/Rendering/HtmlHelperComponentExtensions.cs
index 178ef697dc..16f021574a 100644
--- a/src/Mvc/Mvc.ViewFeatures/src/Rendering/HtmlHelperComponentExtensions.cs
+++ b/src/Mvc/Mvc.ViewFeatures/src/Rendering/HtmlHelperComponentExtensions.cs
@@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
public static class HtmlHelperComponentExtensions
{
///
- /// Renders the .
+ /// Renders the .
///
/// The .
/// The for the component.
@@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
=> RenderComponentAsync(htmlHelper, renderMode, parameters: null);
///
- /// Renders the .
+ /// Renders the .
///
/// The .
/// An containing the parameters to pass
@@ -36,15 +36,35 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
this IHtmlHelper htmlHelper,
RenderMode renderMode,
object parameters) where TComponent : IComponent
+ => RenderComponentAsync(htmlHelper, typeof(TComponent), renderMode, parameters);
+
+ ///
+ /// Renders the specified .
+ ///
+ /// The .
+ /// The component type.
+ /// An containing the parameters to pass
+ /// to the component.
+ /// The for the component.
+ public static Task RenderComponentAsync(
+ this IHtmlHelper htmlHelper,
+ Type componentType,
+ RenderMode renderMode,
+ object parameters)
{
if (htmlHelper is null)
{
throw new ArgumentNullException(nameof(htmlHelper));
}
+ if (componentType is null)
+ {
+ throw new ArgumentNullException(nameof(componentType));
+ }
+
var viewContext = htmlHelper.ViewContext;
var componentRenderer = viewContext.HttpContext.RequestServices.GetRequiredService();
- return componentRenderer.RenderComponentAsync(viewContext, typeof(TComponent), renderMode, parameters);
+ return componentRenderer.RenderComponentAsync(viewContext, componentType, renderMode, parameters);
}
}
}