在登錄時,使用登錄。錯誤:沒有找到'xx'或其主人的視圖或沒有任何視圖引擎支持搜索的位置...在登錄?
用戶:管理員 密碼:XXX
我可以正常登錄。
當您嘗試:
用戶:tavaresdemelo.adv.br 密碼:顯示XX
錯誤:
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
賬戶控制器
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");
}
查看登錄
@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>