I have a problem like this. This my default route config.
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Index", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "App.Controllers" }
);
I need something like this.
www.xx.com/transaction/index/ -> List Transactions
www.xx.com/transaction/new/ ->New Transaction
www.xx.com/transaction/new/XXX -> Edit Transaction
How can I do?
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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.