i'm new in this world, so if I say bad things, psl tell me. I'm trying to run a simple partial login that I can call on any page I want i'm not using a /shared/_loginPartial because i didn't found something who can explain me how to do it. I'm using a simple controller and i just recall it with $(#).load("Page url"); Can someone explain me how to do or help me find some video or page ?!
AccountController.cs
[HttpGet]
[AllowAnonymous]
public IActionResult LoginPartial()
{
return PartialView();
}
[HttpPost]
[AllowAnonymous]
public async Task<IActionResult> LoginPartial(string returnUrl = null)
{
returnUrl ??= Url.Content("~/");
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
if (ModelState.IsValid)
{
// This doesn't count login failures towards account lockout
// To enable password failures to trigger account lockout, set lockoutOnFailure: true
var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Inpu.RememberMe, lockoutOnFailure: false);
if (result.Succeeded)
{
_logger.LogInformation("User logged in.");
return LocalRedirect(returnUrl);
}
if (result.RequiresTwoFactor)
{
return RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe });
}
if (result.IsLockedOut)
{
_logger.LogWarning("User account locked out.");
return RedirectToPage("./Lockout");
}
else
{
ModelState.AddModelError(string.Empty, "Invalid login attempt.");
return PartialView();
}
}
return PartialView();
}
Ex. Index.cshtml
<div id="partialZone">
</div>
<script>
$('#partialZone').load("/Account/LoginPartial");
</script>
thanks in advance for the reply. Please don't be mean, I'm new and learning now