【发布时间】:2016-01-26 08:59:43
【问题描述】:
我无法使用SetAuthCookies 显示已登录的用户保存,我该如何检索它?我还是新手。
这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using logUser.Models;
using logUser.Functions;
namespace logUser.Controllers
{
public class LoginController : Controller
{
// GET: Login
public ActionResult Login()
{
return View();
}
[HttpPost]
public ActionResult DoLogin(logUser.Models.UserInfo u)
{
Employee bal = new Employee();
if (bal.IsValidUser(u))
{
FormsAuthentication.SetAuthCookie(u.UserName, true);
return RedirectToAction("Index", "Home");
}
else
{
return View("Login");
}
}
}
}
注意:我已经配置了 Web.config 谢谢。
【问题讨论】: