Pass two parameters - ASP.NET CORE

Asked

Viewed 618 times

1

I need to pass two parameters to a page, when I’m trying to pass one, I do it this way:

<a asp-page="/ContaReceber/Edit" asp-route-id="@item.Id;" class="btn btn-sm btn-success">Editar</a>

I tried to pass something like:

<a asp-page="/ContaReceber/Edit" asp-route-id="@item.Id; @item.PessoaId" class="btn btn-sm btn-success">Editar</a>

I tried to put only a comma, name the parameter, but it doesn’t work, as I can pass more than one parameter to the page.

  • You have to pass an Asp-route for each parameter. <a Asp-controller="/Contareceber/Edit" Asp-action="Edit" Asp-route-id="@item.Id" Asp-route-username="@item.Username">Edit</a>

1 answer

3


Place asp-route- the name of the route parameter, example:

<a asp-page="/ContaReceber/Edit" 
   asp-route-id="@item.Id" 
   asp-route-PessoaId="item.PessoaId" class="btn btn-sm btn-success">
Editar
</a>

Remember that each route parameter is separated and in the end need not put ; the same is in the question. If you have more parameter just add as it is in the example.

  • This way it works, only there is a problem rs, when I pass this parameter, it is to return to another page, where it would be http://localhost:55695/Pessoa/Edit? id=2 only that at the time of returning, it returns like this, how can I change it? http://localhost:55695/Person/Edit? Personal=3

  • I honestly did not understand what happened @marianac_costa could you explain by exemplifying? (just remembering that the answer put to you is how it works, maybe it lacks to put a route !!! in your page)

  • 1

    I’m sorry, I made a mess here, now I understand, helped me a lot, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.