2010/04/27

[ASP.NET] Forms 登入驗證

命名空間
System.Web.Security

驗證
FormsAuthentication.RedirectFromLoginPage(username, true)

登出
FormsAuthentication.SignOut()

查證是否驗證
User.Identity.IsAuthenticated

ASP.NET MVC (在 Controller 的 Action 前加 Authorize 屬性)
[Authorize]
e.g.
[Authorize]
public ActionResult Index() { return View(); }



相關資料:

[ASP.NET] 類別中讀取 Session

匯入命名空間
Imports System.Web.HttpContext

在類別中使用Session
Current.Session("sessionName")