bu. Her sayfa yüklemesinde veritabanını kontrol etmeniz ve hesabın devre dışı bırakılması durumunda oturum açmanız gerekir. Bunu bir HttpModule kullanarak da başarabilirsiniz, bu da işleri biraz daha temiz hale getirir. Örneğin
:
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");
}
}
}
Bu tam bir örnek ve adapte edilmesi gerekecektir oturumda saklanan bir anahtar kullanılarak kullanıcı getirilirken yöntemi değildir, ancak bu başlangıç almalısınız. Kullanıcı hesabının hala aktif olduğunu kontrol etmek için her bir sayfa yüküne ek bir veritabanı kontrolü eklenecektir, ancak bu bilgiyi kontrol etmenin başka bir yolu yoktur.
Bu yalnızca geçerli kullanıcı oturumu için değil mi? Başka bir kullanıcının oturumunu bırakmak istiyorum ... Oturum (kullanıcı) .Abandon gibi bir şey. – Testing123
@ Testing123 egrunin, her kullanıcının kendi hesabının geçersiz olup olmadığını kontrol etmesinin gerektiği anlamına gelir, öyleyse uygulama çerezlerini kaldırır. – guanome
Downvote FormsAuthentication.SignOut(); – Juan