I am just wondering about the situation where the user may request through unexpected query. Suppose i have the controller action
public ViewResult Details(int id)
{
Description description = db.Descriptions.Find(id);
return View(description);
}
The ideal query in the browser will be /admin/Details?id=1.
What if the user entered the id=-1 or id=a or any other unexpected inputs. How to handle this?
To ensure numeric values, you could add
id = @"\d+"route constraint, and your action will be hit only if requestedidis numeric, otherwise it will return http not found;And in all other cases you should always check user input, something like this:
And user will be notified that he requested resource with invalid identifier