Hi tanws8,
Use BindProperty attribute. Refer below article for more details.
Please refer below sample.
Razor PageModel (Code-Behind)
public class IndexModel : PageModel
{
[BindProperty]
public Guid guid_GroupID { get; set; }
[BindProperty]
public string str_is2FA { get; set; }
public Guid Prop1 { get; set; }
public string Prop2 { get; set; }
public void OnGet()
{
str_is2FA = "2FA";
guid_GroupID = Guid.NewGuid();
}
public void OnPostDownload()
{
Prop1 = guid_GroupID;
Prop2 = str_is2FA;
}
}
Razor Page (HTML)
@page
@model VariablesGiveNull.Pages.IndexModel
@addTagHelper*, Microsoft.AspNetCore.Mvc.TagHelpers
@{
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width-device-width" />
<title>Index</title>
<style type="text/css">
body { font-family: Arial; font-size: 10pt; }
</style>
</head>
<body>
<form method="post">
<input type="hidden" asp-for="str_is2FA" />
<input type="hidden" asp-for="guid_GroupID" />
<input type="submit" value="Download" asp-page-handler="Download" />
<hr />
<label>@Model.Prop2</label>
<br />
<label>@Model.Prop1</label>
</form>
</body>
</html>
Screenshot