Do you use the URL as a navigation aid (aka redirect if URL is incorrect)?
Updated by Brady Stroud [SSW] 1 year ago. See history
123
Figure: Watch the URL working as a navigation aid
MVC gives us great URLs, but you need to help users navigate via the URL. If the user changes a URL, and the route parameters no longer match, you should correct them with a redirect.
public ActionResult Edit(string employeename, int id){var model = _repository.GetEmployee(id);// check for a parameter match and redirect if incorrectif (string.IsNullOrEmpty(employeename) || employeename != model.EmployeeName){return RedirectToAction("Edit", new { employeename = model.EmployeeName, id });}return View(model);}
✅ Figure: Figure: Good example - The comment says it all Wordpress and Stack Overflow have URL formats that do this very well
✅ Figure: Figure: Good example - If the "settimeout-or-setinterval" part of th eURL changes, the page will redirect to the correct location