日期:2014-05-17 浏览次数:20879 次
@using (Html.BeginForm("LogOn", "Account", new { ReturnUrl = Request.QueryString["ReturnUrl"] }, FormMethod.Post))
{...
[HttpPost]
public ActionResult Logon(LogonInfo model, string returnUrl)
{
if (ModelState.IsValid)
{
string[] loginResult;
if (!string.IsNullOrEmpty(model.UserID) && !string.IsNullOrEmpty(model.Password))
{
// 验证登陆
if (this.TryLogin(model.UserID, model.Password, out loginResult))
{
//model.UserName = string.Empty;
//Response.Cookies.Remove(model.UserID);
Response.Cookies.Remove(model.UserID);
// 记住登陆状态
FormsAuthentication.SetAuthCookie(model.UserID, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")