Hi Sherpa,
According to your description, I suggest you could use the temp data , or directly using the querystring to pass the userEmail or user ID to the LoginWith2fs page and then using the usermanager to get the user instead of directly store the whole application user inside the tempdata or the user string.
Why we suggest you use the tempdata to just store the userEmail , since this data will be encrypted automatically. Passing the userinformtion directly inside the url is not recommend and it is not security.
More details, you could refer to below codes:
1.Login page:
Add a new userid like below:
[TempData]
public string UserEmail { get; set; }
Inside the OnPostAsync method set it:
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
{
returnUrl ??= Url.Content("~/");
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
UserEmail = Input.Email;
...
}
Then inside the LoginWith2fs page:
public async Task<IActionResult> OnGetAsync(bool rememberMe, string returnUrl = null)
{
var username = TempData.Peek("UserId").ToString();
var applicationuser = await _userManager.FindByEmailAsync(username);
.....
Result:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.