我有一个名为的控制器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>