Demo Menu

TempData Demo Page 1

The Users Without Passwords Project (UWPP) persists the ChallengeGuid property on the server for response verification with a TempData attribute. TempData is a storage container for data that needs to be available to a separate HTTP request. Once the value has been read, it is marked for deletion and is therefore not available for subsequent requests. See TempData In Razor Pages . This demo transfers the LoginName property from Page 1 to Page 2. Page 2 persists the LoginName and ChallengeGuid properties on the server between the initial request and the callback with TempData attributes. See ASP.NET Core 5.0 - The TempData Challenge .

public class TempDataDemoP1Model : PageModel
    [Display(Name = "Login Name")]
    [StringLength(32, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
    public string LoginNameInput { get; set; }

    public void OnGet()

    public IActionResult OnPost()
        if (!ModelState.IsValid) return Page();

        TempData["LoginName"] = LoginName;

        return RedirectToPage("./TempDataDemoP2");