我有一个控制器动作方法,它返回一个包含带图表的图像的文件:
public ActionResult EfficiencyChart(string id) {
var myChart = new Chart(width: 600, height: 400)
.AddTitle("Chart Title")
.AddSeries(
name: "Employee",
xValue: new[] { "Peter", "Andrew", "Julie", "Mary", "Dave" },
yValues: new[] { "2", "6", "4", "5", "3" })
.Write();
myChart.Save("~/Content/chart", "jpeg");
// Return the contents of the Stream to the client
return base.File("~/Content/chart", "jpeg");
}
如何在EfficiencyChart.cshtml
中呈现它?
答案 0 :(得分:2)
在您的Efficiency.cshtml中,将简单图片代码与Url.Action()
-
<img src="@Url.Action("ActionName","ControllerName",new { id = PassYourIDHere })" />