ASP.Net MVC 5 – Attribute Based Routing Part 3
Overriding a Route Prefix
We can override a Route prefix applied at controller level by using “~” character with Route attribute
[RoutePrefix("Sports")]
public class HomeController : Controller
{
[Route("{category}")]
public ActionResult SomeAction(string category)
{
ViewBag.category = category;
return View();
}
[Route("~/Games/{category}/edit")]
public ActionResult SomeMoreAction(string category)
{
ViewBag.category = category;
return View();
}
}