【发布时间】:2021-03-05 04:19:31
【问题描述】:
我正在构建一个 asp.net 核心 web api 项目。我正在尝试通过以下代码添加搜索查询。但是,我在“视图”中收到“当前上下文中不存在名称视图”的错误。
//https://localhost:44354/api/comments?searchString=Agree
[HttpGet("{searchString}")]
public async Task<IActionResult> Index(string searchString)
{
var comments = from c in _context.Comments
select c;
if (!String.IsNullOrEmpty(searchString))
{
comments = comments.Where(s => s.Comments_content.Contains(searchString));
}
return View(await comments.ToListAsync());
}
【问题讨论】:
标签: asp.net rest asp.net-core asp.net-web-api