Search code examples
c#htmlasp.net-mvcrazor

how to use razor template between " "


I am trying to write razor template in link

 <a asp-action="Details/@(customerModel.CustomerId)" class="button">Detail</a>

but in html it renders like this

https://localhost:44316/User/Details%2F92e48182-6bc8-4c88-8de9-a7e0b5715f2b

the id is 92e48182-6bc8-4c88-8de9-a7e0b5715f2b

why it doesn't render like this?

https://localhost:44316/User/Details/92e48182-6bc8-4c88-8de9-a7e0b5715f2b


Solution

  • Try this:

    
    <a  asp-action="Details" asp-controller="User" asp-route-id="@Model.CustomerId" 
    class="button"> Details </a>