我正在尝试在站点上创建类似向导的工作流程,并且每个步骤都有一个模型。
我有以下操作方法:
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
所有模型类都继承自具有 Step 属性的 BaseModel。具有参数的操作方法具有正确的 AcceptVerbs 约束。
我尝试将所有方法命名为 Create,但这导致了 AmbiguousMatchException。
我现在想做的是为每个动作创建一个自定义路由,但我不知道该怎么做。这是我尝试过的:
routes.MapRoute(
"ElementsCreation",
"Element/Create",
new{controller="Element", action="Create01"},
new{Step="1"}
);
但这不起作用。
任何帮助(关于正确的 MapRoute 调用或不同的方法)将不胜感激。
谢谢