I\'ve been trying to figure out the difference between RenderAction and Action. I don\'t know if I\'m so concerned about the differences at this point, as to why I can\'t ge
The return type of Html.RenderAction
is void
that means it directly render the responses in View where return type of Html.Action is MvcHtmlString
you can catch its render view in the controller and modified it also by using following method
protected string RenderPartialViewToString(string viewName, object model)
{
if (string.IsNullOrEmpty(viewName))
viewName = ControllerContext.RouteData.GetRequiredString("action");
ViewData.Model = model;
using (StringWriter sw = new StringWriter())
{
ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);
ViewContext viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
viewResult.View.Render(viewContext, sw);
return sw.GetStringBuilder().ToString();
}
}
This will return the Html string of the View.
Try:
@{Html.RenderAction("Breadcrumb", "Navigation", new {SeoUrl = Model.CarlineBucket.SEOURLName});}
@Html.RenderAction()
generates a write call to output something on the page and in your case you are not doing so because RenderAction
renders the result directly to the Response.
Instead of
@Html.RenderAction()
Use
@{Html.RenderAction();}
From Phil Haack:
The difference between the two is that
Html.RenderAction
will render the result directly to the Response (which is more efficient if the action returns a large amount of HTML) whereasHtml.Action
returns a string with the result.