없습니다입니다. 각 페이지로드시 데이터베이스를 점검하고 계정이 사용 불가능한 경우 로그 아웃해야합니다. HttpModule을 사용하여이 작업을 수행 할 수 있습니다. 이렇게하면 작업이 조금 더 깨끗해집니다. 예를 들어
:
public class UserCheckModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);
}
public void Dispose() {}
private void OnPreRequestHandlerExecute(object sender, EventArgs e)
{
// Get the user (though the method below is probably incorrect)
// The basic idea is to get the user record using a user key
// stored in the session (such as the user id).
MembershipUser user = Membership.GetUser(Guid.Parse(HttpContext.Current.Session["guid"]));
// Ensure user is valid
if (!user.IsApproved)
{
HttpContext.Current.Session.Abandon();
FormsAuthentication.SignOut();
HttpContext.Current.Response.Redirect("~/Login.aspx?AccountDisabled");
}
}
}
이 완전한 예를 들어, 및 적응해야합니다 세션에 저장된 키를 사용하여 사용자를 검색하는 방법은 아닙니다, 그러나 이것은 당신이 시작하는 것이다. 사용자 계정이 아직 활성 상태인지 확인하기 위해 각 페이지로드시 추가 데이터베이스 확인이 필요하지만이 정보를 확인할 수있는 다른 방법은 없습니다.
출처
2010-06-23 03:55:32
Mun
현재 사용자의 세션에서만 사용하지 않습니까? 다른 사용자의 세션을 포기하고 싶습니다. 세션 (사용자)과 같은 것입니다. – Testing123
@ Testing123 egrunin은 모든 사용자가 자신의 계정이 유효하지 않은지 확인하기 위해 검사하고, 그렇다면 응용 프로그램이 쿠키를 제거한다는 것을 의미합니다. – guanome
FormsAuthentication.SignOut()이 필요하기 때문에 Downvote; – Juan