I have Controller name: About and Action name: Index. But I want the URL to be like this (action name will be dynamically)
www.example.com/home/aaa www.example.com/home/bbb www.example.com/home/ccc
Routing
routes.MapRoute(
name: "Home",
url: "{controller}/{name}",
defaults: new { controller = "Home", action = "Index"}
Controller
public class AboutController : Controller
{
public ActionResult Index(string name)
{
return View();
}
}
}
View
@{
ViewBag.Title = "Index";
}
<h2>Index About</h2>
Barbara Jones
10-Nov-2014This should work.
Make sure your default route exists and comes after About route