我有部分观点(关于用户名称、密码和分门纽顿的行文记录仪),而部分意见则在我的休庭上使用。
So, on my _layout page, I have:
<div style="text-align: right">
@Html.Partial("_LoginPartial")
</div>
我的——总行有以下法典:
@if (Request.IsAuthenticated)
{
<textarea>Welcome!
[ @Html.ActionLink("Log Off", "Logout", "Account")]</textarea>
}
else
{
@Html.Partial("~/Views/Account/Index.cshtml")
}
显示标识箱的指数文件就是这样:
@using GalleryPresentation.Models
@model LoginModel
<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
@using (Html.BeginForm("index", "Account"))
{
<table>
<tr>
<td>@Html.LabelFor(m => m.Username)</td>
<td>@Html.TextBoxFor(m => m.Username)</td>
</tr>
<tr>
<td>@Html.LabelFor(m => m.Password)</td>
<td>@Html.PasswordFor(m => m.Password) kjkj</td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Login"/></td>
</tr>
<tr>
<td colspan="2">@Html.ValidationSummary()</td>
</tr>
</table>
}
我的账户 我有以下法典:
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(LoginModel loginModel)
{
if(ModelState.IsValid)
{
var g = new GallaryImage();
var user = g.LoginUser(loginModel.Username, loginModel.Password);
if(user != null)
{
FormsAuthentication.SetAuthCookie(user.username, false);
return RedirectToAction("Index", "Home");
}
ModelState.AddModelError("", "Invalid Username/Password");
}
return View(loginModel);
}
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home");
}
I have breakpoints on all methods - but they never get hit. Pressing the submit button simply changes my URL to:
http://localhost:8741/?Username=myusername&Password=mypassword
谁能发现我正在制造的错误?