Skip to content

Commit

Permalink
"RenderViewComponentToString" method now supports arguments (for a vi…
Browse files Browse the repository at this point in the history
…ew component)
  • Loading branch information
AndreiMaz committed Sep 6, 2017
1 parent b774612 commit 21aa362
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ public abstract class BaseController : Controller
/// Render component to string
/// </summary>
/// <param name="componentName">Component name</param>
/// <param name="arguments">Arguments</param>
/// <returns>Result</returns>
protected virtual string RenderViewComponentToString(string componentName)
protected virtual string RenderViewComponentToString(string componentName, object arguments = null)
{
//original implementation: https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ViewComponentResultExecutor.cs
//we customized it to allow running from controllers
Expand All @@ -57,7 +58,7 @@ protected virtual string RenderViewComponentToString(string componentName)

var context = actionContextAccessor.ActionContext;

var viewComponentResult = ViewComponent(componentName);
var viewComponentResult = ViewComponent(componentName, arguments);

var viewData = this.ViewData;
if (viewData == null)
Expand Down

0 comments on commit 21aa362

Please sign in to comment.