0
我试图在网站上创建类似向导的工作流程,并且我为每个步骤都有一个模型。ASP.Net MVC:根据参数值映射路由
我有以下操作方法:
public ActionResult Create();
public ActionResult Create01(Model01 m);
public ActionResult Create02(Model02 m);
public ActionResult Create03(Model03 m);
而且我希望用户看到地址
/Element/Create
/Element/Create?Step=1
/Element/Create?Step=2
/Element/Create?Step=3
所有的模型类从具有步骤属性BaseModel继承。 具有参数的操作方法具有正确的AcceptVerbs约束。
我尝试命名所有方法创建,但导致AmbiguousMatchException。
我现在想要做的是为每个动作创建一个自定义路由,但我无法弄清楚如何去做。 这是我试过的:
routes.MapRoute(
"ElementsCreation",
"Element/Create",
new{controller="Element", action="Create01"},
new{Step="1"}
);
但是这不起作用。
任何帮助(在正确的MapRoute调用或可能是一种不同的方法)将不胜感激。
谢谢