Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: The view 'xx' or its master was not found or no view engine supports the searched locations... on logon?

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>
like image 975
ridermansb Avatar asked Aug 05 '11 23:08

ridermansb


2 Answers

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!

like image 145
dizzwave Avatar answered Oct 17 '22 07:10

dizzwave


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.

like image 37
Dragos Durlut Avatar answered Oct 17 '22 05:10

Dragos Durlut