简体   繁体   中英

Semicolon gets appended on href URL by using Url.Action (ASP.NET MVC)

This is a snippet of my View getItems.cshtml

<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>

The dropdown works as expected but the problem is the href

Expected: countries/Details/id
Actual: countries/Details/id;

Where is the semicolon getting appended from?
How do I remove the semicolon?

yo have semicolon in the tag new { id = index} ); . please remove it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM