【问题标题】:Semicolon gets appended on href URL by using Url.Action (ASP.NET MVC)使用 Url.Action (ASP.NET MVC) 将分号附加到 href URL
【发布时间】:2021-11-28 01:48:52
【问题描述】:

这是我的视图 getItems.cshtml 的 sn-p

<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
    @{int index = 1;}
    @foreach (var o in ViewBag.CountryList)
    {
                <li><a class="dropdown-item" href="@Url.Action("Details", "countries", new { id = index} );">@o</a></li>
                index++;
    }
</ul>

下拉菜单按预期工作,但问题是 href

预期:国家/地区/详细信息/id
实际:国家/地区/详细信息/id;

从哪里附加分号?
如何删除分号?

【问题讨论】:

  • index} );" 在这里?

标签: c# asp.net-mvc bootstrap-4


【解决方案1】:

标签new { id = index} ); 中有分号。请删除它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-20
    • 2021-07-05
    相关资源
    最近更新 更多