0
我正在嘗試爲有效用戶設置cookie,但我無法使用SetAuthCookie
作爲拋出提到的錯誤。我添加了System.Web.Security
名稱空間,但仍無法使用它。我需要爲此安裝一些特殊的nuget包嗎?名稱空間「FormAuthentication」中不存在類型或名稱空間名稱「SetAuthCookie」
以下是我在控制器的操作方法都試過:
[HttpPost]
public ActionResult Login(User user)
{
if (user.Username.ToLower() == "admin" || user.Password == "admin")
{
FormAuthentication.SetAuthCookie(user.Username, false);
}
return View();
}