I'm trying to redirect users to a 'Delete' page in a .NET Core application, after they press a delete button next to the item that they intend to delete.
I'm using: RedirectToPage("./Delete", new { videoId = Video.Id }), passing in an id and redirecting users to a view, but at the moment I'm getting an error saying "This page isn't working at the moment - localhost redirected you too many times".
Is there another way of coding this so that the page is built and the user is sent straight through? I have also tried using Page() but I am aware that this cannot take any arguments.
Code:
public IActionResult OnGet(int? videoId)
{
Video = videoId.HasValue ? _videoData.GetVideo(videoId.Value)
: new Video
{
ReleaseDate = DateTime.Now.Date
};
return Video == null ? RedirectToPage("./VideoError", new
{
message = "The video does not exist"
}) : (IActionResult)
RedirectToPage("./Delete", new { videoId = Video.Id });
}
Result:
Page it should redirect to:
Thanks, Robert

