Can anyone help me filtering URL parameters because I just can't find correct answer for that.
So lets say I have URL like this Custom/Action/FirstParm/2
If I have last parameter only 1,2,3 ids in database and I manually enter 10 in URL I want to be redirected somewhere as default. How can I achieve this?
Thanks.
I don't think this is possible with the url filtering, I think you'll end up having to try to load the record from the database and redirect to a page (or show a message on the existing page) indicating that the record does not exist.
public ActionResult Detail(int id) {
var item = _service.Search(x=>x.Id == id).FirstOrDefault();
if (item == null)
return RedirectToAction("DoesNotExist");
return View(viewModelWithItem);
}