I am using @Html.Action to call contoller action to return a string. I want to save the string to a variable inside razor as it is comma-seperated.
@Html.Action("GetCategories", new { SP = @ViewBag.Name, SD = "Cad" }).ToString();
//@String s = save above string in here
//@string[] arrS = s.Split(',');
@String test = @Html.Action(......) //tried this but does NOT work.
Public ActionResult GetCategories(string SP, string SD)
{
//Code missing
return Content(return "sugar");
}
How can I save the Html.Action returned data to a string ?
@{string test = Html.Action("SomeAction").ToString();}works for me in MVC5 (sorry get test under MVC3).