Hi @Ahmed Abd El Aziz,
Do you want to redirect to another page with parameters? Like this:
Index.cshtml.cs:
public class IndexModel : PageModel
{
[BindProperty]
public string username { get; set; }
[BindProperty]
public string email { get; set; }
public IActionResult OnGet()
{
username = "Tom";
email = "Tom@email.com";
return Page();
}
public IActionResult OnPost()
{
return RedirectToPage("/Privacy", new {username = username, email = email });
}
}
Index.cshtml:
@page
@model IndexModel
<div>
<form method="post">
<div>
<input type="hidden" asp-for="username" />
<input type="hidden" asp-for="email"/>
</div>
<div>
<input type="submit" value="Submit" />
</div>
</form>
</div>
Privacy.cshtml.cs:
public class PrivacyModel : PageModel
{
public void OnGet(string username, string email)
{
}
}
TestResult:
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
Chen Li