I work on razor page asp.net . I face issue my issue values on get reset after click submit button so when click submit button and check values on POST I found it become null
so How to avoid this behavior OR with another meaning how to retain values on get without reset when click submit button
from my debug details as below
1 - when page load i check user id it have value 9595
public void OnGet()
{
string MyUserData = Request.Cookies["myUserData"];
UserAuthResponse? userAuthResponse = System.Text.Json.JsonSerializer.Deserialize(MyUserData);
string UserID = userAuthResponse.Data.UserID;
}
2 - Now I will click submit button so break point hit on post method
public async Task OnPost(UC.ADC.Core.Entities.SQL.Branch branch)
{
//userAuthResponse.Data.UserID become null
}
when check values of userAuthResponse.Data.UserID it become null
so how to preserve or retain value of userAuthResponse.Data.UserID after make get to use it on post method
form view as below :
issue debug details as below :

Amit MohantyPosted Jun 8, 2023, 5:32 AM
In order to retain values between GET and POST requests in Razor Pages, you can make use of hidden fields or session variables.
Use a hidden field in your Razor Page to store the value of userAuthResponse.Data.UserID.
In your POST method, you can retrieve the value of
UserIDfrom the form data:Alternatively, you can also use session variables to store the value of
UserIDbetween requests.Rajkiran SwainPosted Jun 8, 2023, 5:06 AM