Tenho uma tela de Login padrão, onde tem a funcionalidade "Esqueci a senha", que ao ser clicado irá verificar o número do ID do usuário digitado na tela, e caso for respeitado, irá abrir uma nova View com essa mensagem:
Nota XPTO = dbo.Clientes.CliEmail
"Enviamos um e-mail para o endereço XPTO com instruções de recuperação"
Porém no método que deveria retornar esse dado para view da esse erro:
Stack
InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'System.String', but this ViewDataDictionary instance requires a model item of type 'PCI.EV.Models.Clientes'.
Seguem código.
AccountsController(método que consulta o e-mail de acordo com o ID):
public IActionResult ForgetMyPassword(Clientes cli)
{
Clientes objCli = new Clientes();
var client = objCli.ConsultarEmail(cli.CliCodigo, _config);
if (client != null)
{
return View("RememberPassword", client);
}
return View("Login");
}
na variável client é carregado o e-mail, porém ele não abre a View.
View da mensagem(RememberPassword)
Obs. Tanto a view de Login, quanto a view RememberPassoword, pertencem ao mesmo controller.
@model PCI.EV.Models.Clientes
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>RememberPassword</title>
<environment include="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment exclude="Development">
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
<environment include="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery"
crossorigin="anonymous"
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
crossorigin="anonymous"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>
</head>
<body>
<div class="container body-content">
<div class="form-group">
<br />
<label class="control-label">Enviaremos um e-mail com instruções para redefinição de senha.</label>
<input type="email" asp-for="CliEmail" style="width: 150px" />
<br />
</div>
</div>
</body>
</html>