G
GZERO1
Guest
Hi,
Inquiry:
How do I pass two parameters (the personId and person) to the function http.PutJsonAsync() so that the webapi controller can receive it in the public async Task<IActionResult> PutPerson(int id, Person person)?
Details:
In my Blazor component, I have the following code.
@code {
[Parameter]
public int personId { get; set; }
Person person = new Person();
protected override async Task OnParametersSetAsync()
{
person = await http.GetJsonAsync<Person>($"api/people/{personId}");
}
async Task EditPerson()
{
await http.PutJsonAsync("api/people", person); // <-- How do I pass the personId and person parameters here?
navigationManager.NavigateTo("people");
}
}
In my WebApi Controller, I have the following code.
[HttpPut("{id}")]
public async Task<IActionResult> PutPerson(int id, Person person)
{
// some code here
}
Development Background:
1. I'm a beginner and trying to learn Blazor using EF Core 3.0.
2. Using Visual Studio 2019 Community 16.3.0
Continue reading...
Inquiry:
How do I pass two parameters (the personId and person) to the function http.PutJsonAsync() so that the webapi controller can receive it in the public async Task<IActionResult> PutPerson(int id, Person person)?
Details:
In my Blazor component, I have the following code.
@code {
[Parameter]
public int personId { get; set; }
Person person = new Person();
protected override async Task OnParametersSetAsync()
{
person = await http.GetJsonAsync<Person>($"api/people/{personId}");
}
async Task EditPerson()
{
await http.PutJsonAsync("api/people", person); // <-- How do I pass the personId and person parameters here?
navigationManager.NavigateTo("people");
}
}
In my WebApi Controller, I have the following code.
[HttpPut("{id}")]
public async Task<IActionResult> PutPerson(int id, Person person)
{
// some code here
}
Development Background:
1. I'm a beginner and trying to learn Blazor using EF Core 3.0.
2. Using Visual Studio 2019 Community 16.3.0
Continue reading...