【发布时间】:2014-07-07 20:40:00
【问题描述】:
我只有 1 个控制器,并且仅在我的示例中具有 1 个操作,如下所示:
//
// GET: /Home/
public ActionResult Index(string source,string id)
{
return View();
}
我为此操作注册了 2 条路线,例如 -:
routes.MapRoute(
name: "Default2",
url: "{source}/{id}",
defaults: new { controller = "Home", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "",
defaults: new { controller = "Home", action = "Index", source="source1", id = UrlParameter.Optional }
);
当我调用默认时,它调用Index 动作,这没关系
当我这样打电话时,/source1/12 - 它有效。
但是当我像这样/source1/12.0 打电话时 - 它不起作用并显示 404 ..
谁能指出为什么会这样?
【问题讨论】:
-
你能显示源动作吗?
-
这是因为你的行为会像
public ActionResult Source(int id) -
public ActionResult Index(string source,string id) { return View(); }
-
唯一的区别是当我像 /sourceId/12 一样调用时 - 它可以工作,但使用 /sourceId/12.0 - 它不(12.0)不工作,而 /sourceid/12.0/ 工作(使用 / in最后)
-
可能是因为点(.)
标签: asp.net-mvc