I know I have some silly error in here. But I cant see it.
I am adapting the search from a tutorial to work for me...but it isn't.
Controller:
public async Task<IActionResult> Index(string searchString)
{
ViewData["CurrentFilter"] = searchString;
var site = from s in _context.Sites
select s;
if (!String.IsNullOrEmpty(searchString))
{
site = site.Where(s => s.SiteName.Contains(searchString));
}
return View(await _context.Sites.ToListAsync());
}View
<form asp-action="Index" method="get"><div class="form-actions no-color"><p>
Find by name: <input type="text" name="SearchString" value="@ViewData["currentFilter"]"/><input type="submit" value="Search" class="btn btn-default" /><a asp-action="Index">Back to list</a></p></div></form>