I am new to Core and razor programming and in my project I have to add a user to the _Context then pass the ID of the added us
_Context.StaffMember.Add(StaffMember);
await _Context.SaveChangesAsync();
Id = StaffMember.UserId;
return RedirectToPage("./Invite", Id);
When I tested the code, I can see the ID correctly, but it is not getting passed to the other page
public async Task<IActionResult> OnGetAsync(int? id){}
and the id is null. I tried the asp-route-id="Model.Id" on the user page, but it is not working.
<input type="submit" value="Add" class="btn btn-primary" asp-route-id="Model.Id"/>
Can anyone help me with this ?
解
return RedirectToPage("./Invite", new { id = Id})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.