【发布时间】:2019-07-02 21:01:59
【问题描述】:
简单地做:
[HttpGet("{id}", Name = "Get")]
public ActionResult Get(int id)
{
var result = new Pages.IndexModel().Page();
result.ViewData["ID"] = id;
return result;
}
给出The context used to execute 'context' must be an instance of 'Page'. Returning a 'PageResult' from a controller is a not supported.的错误
我只想将数据传递到页面并查看它。
【问题讨论】:
-
您想使用两条路线显示同一个页面吗?从控制器返回页面有什么意义?您可以重定向到页面而不是返回它。
-
我想根据url返回数据。就像有人去 /thread/54 它返回一个页面,其中包含来自数据库的数据,使用 54 进行查询
标签: asp.net-core razor controller