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

Time:10-08

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?

CodePudding user response:

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

  • Related