S. *_*dal 7 c# asp.net-core-2.0 razor-pages
There are two page one is Edit page and the other is Main Detail page which is combined data of some entities In edit page : after edit done and I posted the data to API as below
public async Task<IActionResult> OnPostAsync(Guid id)
{
ManufacturerAuthorizedPerson.Id = id;
ManufacturerAuthorizedPerson.ManufacturerId = GetManufacturerId(id);
if (!ModelState.IsValid)
{
await OnGetAsync(id);
return Page();
}
HttpResponseMessage = await httpSystemApi.PutAsync("ManufacturerAuthorizedPersons", ManufacturerAuthorizedPerson);
if (HttpResponseMessage.IsSuccessStatusCode)
{
return RedirectToPage("../Detail", ManufacturerAuthorizedPerson.ManufacturerId);
}
else
{
await OnGetAsync(id);
return Page();
}
}
Run Code Online (Sandbox Code Playgroud)
The ID in OnPostMethod(Guid id) is the value of edited entity. I am using the value and get the other one to use in route as below to get detail page.
ManufacturerAuthorizedPerson.ManufacturerId = GetManufacturerId(id);
Run Code Online (Sandbox Code Playgroud)
but on the detail page the value coming from route ID that I sent from Edit pages post method like below
return RedirectToPage("../Detail", ManufacturerAuthorizedPerson.ManufacturerId);
Run Code Online (Sandbox Code Playgroud)
do not show up as route URL.Instead of ID is beeing same as I wa sent to Edit Page. Little bit confused. Need help please.
ED?T :
changed the route vale as below :
if (HttpResponseMessage.IsSuccessStatusCode)
{
return RedirectToPage("../Detail", new {id = ManufacturerAuthorizedPerson.ManufacturerId });
}
Run Code Online (Sandbox Code Playgroud)
and I am able to send the ID successfuly.
Bog*_*dan 10
突然我找到了解决这个问题的简单方法。您应该输入:
return RedirectToPage("../Detail", new {id = ManufacturerAuthorizedPerson.ManufacturerId});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6385 次 |
| 最近记录: |