I have a default Login screen, where you have the "Forgot Password" feature, which when clicked will check the user ID number entered on the screen, and if it is respected, it will open a new View with this message:
Note XPTO = dbo.Clients.CliEmail
"We sent an email to the XPTO address with instructions recovery "
But in the method that should return this data to view this error:
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.Customers'.
Following code.
AccountsController (method that queries the email according to the 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");
}
In the client variable, the email is loaded, but it does not open the View.
MessageView(RememberPassword)
Obs.BoththeLoginviewandtheRememberPassowordviewbelongtothesamecontroller.
@modelPCI.EV.Models.Clientes<!DOCTYPEhtml><html><head><metaname="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>