我有这样的问题。这是我的默认路由配置。
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Index", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "App.Controllers" }
);
我需要这样的东西。
www.xx.com/transaction/index/ - >列表交易
www.xx.com/transaction/new/ - >新交易
www.xx.com/transaction/new/XXX - >编辑交易
我该怎么办?
答案 0 :(得分:0)
public class TransactionController
{
public ActionResult Index()
{
return View("List", yourList);
}
[HttpGet]
public ActionResult New(int? id)
{
var model = new Model();
if(id.HasValue)
{
model = Get(id.Value);
}
return View("New", model);
}
}