Reputation: 85
My solution was working very well, suddenly I got (page not found 404 error) for two controllers only for Index Actions !! and the other Index actions in other controllers are working fine.
UsersController
public async Task<IActionResult> Index()
{
return View(await _context.Users.ToListAsync());
}
[HttpPost]
public async Task<IActionResult> Index([FromForm] string search)
{
if (!User.Identity.IsAuthenticated) RedirectToAction("Index", "Home");
if (!string.IsNullOrWhiteSpace(search))
{
search = search.Trim().ToLower();
ViewBag.Search = search;
return View(_context.Users.Where(x => x.NormalizedUsername.Contains(search)).ToList());
}
else
return View(await _context.Users.ToListAsync());
}
any help/clue where I should check? thanks
Upvotes: 2
Views: 578
Reputation: 27825
I got (page not found 404 error) for two controllers only for Index Actions
Please check the conventional routing you configured in StartUp.Configure
method, then compare it with your actual request URL and check if some required segment or data is missing in request URL.
And please check if you are using any attribute route or URL rewriting rule, which might cause similar issue.
Besides, you can try to modify log level to get detailed routing diagnostic logs.
Upvotes: 1