0

という名前のコントローラーと という名前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>
4

3 に答える 3

0
routes.MapRoute(
    name: "About",
    url: "about/{name}/{id}",
    defaults: new { controller = "About", action = "Index", id=UrlParameter.Optional}
于 2013-11-19T08:54:45.700 に答える