首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MVC 5和环境路由参数的问题

MVC 5和环境路由参数的问题
EN

Stack Overflow用户
提问于 2014-07-24 16:08:41
回答 1查看 84关注 0票数 0

链接到我的示例项目

在上面的项目(MVC 5)中,我与Html.ActionLink有问题,似乎没有从当前的页面中清除路由参数。

对一个页面上的Html.ActionLink的完全相同的调用会产生不同的结果,这取决于您的路径“有多深”。下面是我的示例控制器

代码语言:javascript
复制
    // 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");
    }

下面是来自示例/索引视图的片段

代码语言:javascript
复制
@Html.ActionLink("Link", "Example", new { controller = "Sample", categoryid = 100 }, null)

这将产生以下HTML:http://localhost:2762/sample/example/100

下面是示例/示例视图中的一个片段

代码语言:javascript
复制
    @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,它显然不去你想要它去的地方。

这基本上是一个浏览产品类别的面包屑场景。

有什么想法可以解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-25 05:55:49

将控制器中的示例()更改为Example2()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24938830

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档