In view logon, log on with.
User: admin Password: xxx
I can log in normally.
When you try to:
User: tavaresdemelo.adv.br Password: xx
The error is displayed:
The view 'tavaresdemelo.adv.br' or ITS master was not found or the view engine supports the searched locations. The Following Were searched locations: ~ / Views / account / tavaresdemelo.adv.br.aspx ~ / Views / account / tavaresdemelo.adv.br.ascx ~ / Views / Shared / tavaresdemelo.adv.br.aspx ~ / Views / Shared / tavaresdemelo.adv.br.ascx ~ / Views / account / tavaresdemelo.adv.br.cshtml ~ / Views / account / tavaresdemelo.adv.br.vbhtml ~ / Views / Shared / tavaresdemelo.adv.br.cshtml ~ / Views / Shared / tavaresdemelo.adv.br.vbhtml
Account Controller
public ActionResult LogOn()
{
return View();
}
[HttpPost]
public ActionResult LogOn(string userName, string password, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(userName, password))
{
FormsAuthentication.SetAuthCookie(userName, false);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
return Redirect(returnUrl);
return RedirectToAction("Index", "Home");
}
ModelState.AddModelError("", "Usuário ou senha estão inválidos");
}
// If we got this far, something failed, redisplay form
return View(userName);
}
public ActionResult LogOff()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home");
}
View Logon
@model string
@{
ViewBag.Title = "Login";
}
<div id="login">
<h2>@ViewBag.Title</h2>
@Html.ValidationSummary(true, "Erro ao tentar efetuar o login.")
@using (Html.BeginForm())
{
<fieldset class="login">
<legend>Entre com seu usuário e senha</legend>
<div class="inline">
@Html.Label("userName", "Usuário: ")
@Html.TextBox("userName", Html.Encode(Model))
@Html.ValidationMessage("userName")
</div>
<div class="inline">
@Html.Label("password", "Senha: ")
@Html.Password("password")
@Html.ValidationMessage("password")
</div>
<div class="form-buttons">
<input type="submit" class="button" value="Login" title="Login" />
</div>
</fieldset>
}
</div>
This line
return View(userName);
tells the framework to load a view called userName (or in this case tavaresdemelo.adv.br). That is why you are getting the error that it can't find the view called tavaresdemelo.adv.br.aspx, etc. I think what you're trying to do would be
return View();
or
return View("logon");
or whatever the name of the view you're trying to reload is.
I hope that helps!
For other instances of this error, return View("logon")
does not work for me.
I have found out that return RedirectToAction("View", "Controller")
does solve this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With