在上面的项目(MVC 5)中,我与Html.ActionLink有问题,似乎没有从当前的页面中清除路由参数。
对一个页面上的Html.ActionLink的完全相同的调用会产生不同的结果,这取决于您的路径“有多深”。下面是我的示例控制器
// GET: Sample
public ActionResult Index()
{
return View("Index");
}
[Route("sample/example/{categoryid}")]
public ActionResult Example(int categoryID)
{
ViewBag.categoryID = categoryID;
return View("Example");
}
[Route("sample/example/{parentcategoryid:int}/{categorydepth:int}")]
public ActionResult Example(int parentcategoryID, int categorydepth)
{
ViewBag.parentcategoryID = parentcategoryID;
ViewBag.categorydepth = categorydepth;
return View("Example");
}下面是来自示例/索引视图的片段
@Html.ActionLink("Link", "Example", new { controller = "Sample", categoryid = 100 }, null)这将产生以下HTML:http://localhost:2762/sample/example/100
下面是示例/示例视图中的一个片段
@Html.ActionLink("Link", "Example", new { controller = "Sample", categoryid = 100 }, null)
<br />
@Html.ActionLink("Deeper Link", "Example", new { controller="Sample", parentcategoryid=9999, categorydepth=2})第一次点击索引view...the“链接”中的链接时,http://localhost:2762/sample/example/100是相同的。
如果你点击“更深的链接”,你会得到同样的视图-- again...however --“链接”Html是now:http://localhost:2762/sample/example/9999/2?categoryid=100,它显然不去你想要它去的地方。
这基本上是一个浏览产品类别的面包屑场景。
有什么想法可以解决这个问题吗?
发布于 2014-07-25 05:55:49
将控制器中的示例()更改为Example2()
https://stackoverflow.com/questions/24938830
复制相似问题