scr*_*pni 3 asp.net-mvc razor asp.net-mvc-3
我有一个动作返回图像:
public void SensorData(int id, int width = 300, int height = 100)
{
using (var repo = new DataRepository())
{
var sensor = repo.GetSensor(id);
if (sensor == null) return;
var chart = new Chart(width, height);
chart.AddSeries(name: "Values",
chartType: "line",
xValue: sensor.DataValues.Select(s => s.Date).ToList(),
yValues: sensor.DataValues.Select(s => s.Value).ToList());
chart.Write();
}
}
Run Code Online (Sandbox Code Playgroud)
当我从浏览器调用它时,此操作呈现正常(例如controller_name/SensorData/6).问题是,当我尝试使用Html.RenderAction查看它时,我在我的视图上得到以下编译异常:
'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)'的最佳重载方法匹配具有一些无效参数.
这是生成异常的代码:
@Html.RenderAction("SensorTypes", new { id = 6});
Run Code Online (Sandbox Code Playgroud)
关于可能导致这种情况的任何想法?
谢谢
你有两种可能性:
@{Html.RenderAction("SensorTypes", new { id = 6 });}
Run Code Online (Sandbox Code Playgroud)
要么:
@Html.Action("SensorTypes", new { id = 6 })
Run Code Online (Sandbox Code Playgroud)
使用WebForms视图引擎将其与其等效项进行对比:
<% Html.RenderAction("SensorTypes", new { id = 6 }); %>
<%= Html.Action("SensorTypes", new { id = 6 }) %>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2249 次 |
最近记录: |