Html.RenderAction() and Html.Action() methods are available in ChildActionExtensions (System.Web.Mvc.Html) class in ASP.NET MVC. Generally both methods are used for calling action methods or child action methods and rendering the result of action method in view.
@Html.Action() – Invokes the specified child action method and returns the result as an HTML string.
@{ Html.RenderAction(); } – Invokes the specified child action method and renders the result inline in the parent view. This method is more efficient if the action returns a large amount of HTML.
//renders as a string @Html.Action("GetNews", "Home", new { category = "Sports"})
//renders in-place @{ Html.RenderAction("GetNews", "Home", new { category = "finance"}); }
Here are the method signatures:
namespace System.Web.Mvc.Html { public static class ChildActionExtensions { public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName); public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, object routeValues); public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, RouteValueDictionary routeValues); public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, string controllerName); public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues); public static MvcHtmlString Action(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues); public static void RenderAction(this HtmlHelper htmlHelper, string actionName); public static void RenderAction(this HtmlHelper htmlHelper, string actionName, object routeValues); public static void RenderAction(this HtmlHelper htmlHelper, string actionName, RouteValueDictionary routeValues); public static void RenderAction(this HtmlHelper htmlHelper, string actionName, string controllerName); public static void RenderAction(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues); public static void RenderAction(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues); } }
View Comments (0)