In ASP.NET Core 5, when I used asp-route-...
I could get the URL like this: /Member/Update/2
. But now it is generated like this: /Member/Update?memberId=2.
I don’t understand what changed in 8.0 that makes me include it in my [HttpGet]
as [HttpGet("Update/{memberId}")]
. I am feeling like something is missing. Do I remember it wrong, or did they change it in newer versions? Is there any other way to change this behaviour?
My routing:
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
My Index view:
<td class="d-flex justify-content-center">
<a asp-action="Info" asp-route-memberId="@item.Id" class="btn btn-info btn-rounded btn-fw px-4 py-2 mx-1">View</a>
<a asp-action="Update" asp-route-memberId="@item.Id" class="btn btn-warning btn-rounded btn-fw text-white px-4 py-2 mx-1">Update</a>
<a asp-action="SafeDelete" asp-route-memberId="@item.Id" class="btn btn-danger btn-rounded btn-fw px-4 py-2 mx-1">Delete</a>
</td>
My controller:
[HttpGet]
public async Task<IActionResult> Update([FromRoute]int memberId)
{
var member=await _memberRepository.GetNonDeletedMemberById(memberId);
var updateMemberVM = _mapper.Map<UpdateMemberVM>(member);
return View(updateMemberVM);
}
I know there is a question like this, but I want to know if they changed the behaviour as I remember using it in 5.0 without needing specify my route in HttpGet. Please, let me know if you have any answers before considering closing the question because of duplicate
. Thanks in advance!