Works as expected.
You only set the values on a post. A redirect is a get. So if you do a get after the post, only the attribute code will be processed. At the attribute value is set in the get, that value is copied.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
.Net Core 5 razor pages, using TempData, direct or annotation gives different results;
public class TestModel : PageModel
{
[TempData]
public string Test { get; set; }
public async Task<IActionResult> OnPostAsync()
{
TempData["direct"] = "Test-Direct";
Test = "Test-Annotation";
return Page();
}
}
.chtml Page;
@if (TempData["direct"] != null)
{
@TempData["direct"]
}
@if (Model.Test != null)
{
@Model.Test
}
After return Page();
And then resend browser link(like RedirectToPage)
What is the problem?
Works as expected.
You only set the values on a post. A redirect is a get. So if you do a get after the post, only the attribute code will be processed. At the attribute value is set in the get, that value is copied.