という名前のコントローラーと という名前About
のアクションがありIndex
ます。URL を次のようにしたい (アクション名は動的になります):
www.example.com/about/aaa
www.example.com/about/bbb
www.example.com/about/ccc
ルーティング
routes.MapRoute(
name: "About",
url: "{controller}/{name}",
defaults: new { controller = "About", action = "Index"}
コントローラ
public class AboutController : Controller
{
// GET: /About/
public ActionResult Index(string name)
{
return View();
}
}
意見
@{
ViewBag.Title = "Index";
}
<h2>Index About</h2>