日期:2014-05-17 浏览次数:21064 次
@using (Html.BeginForm("LogOn", "Account", new { Request.ServerVariables["http_referer"] }, FormMethod.Post))
{...
[HttpPost]
public ActionResult Logon(LogonInfo model, string returnUrl)
{
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("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}