【发布时间】:2013-11-19 08:50:39
【问题描述】:
我有一个名为 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>
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 asp.net-mvc-routing mvcroutehandler