Aracılığıyla paylaş


MobileFormsAuthentication Sınıf

Tanım

Dikkat

The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.

Uygun URL'lere uygun kimlik doğrulama bilgilerini ekleyerek tanımlama bilgisi olmayan cihazları destekler. ASP.NET mobil uygulama geliştirme hakkında bilgi için bkz. ASP.NET ile Mobile Apps & Siteleri.

public ref class MobileFormsAuthentication
public class MobileFormsAuthentication
[System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
public class MobileFormsAuthentication
type MobileFormsAuthentication = class
[<System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")>]
type MobileFormsAuthentication = class
Public Class MobileFormsAuthentication
Devralma
MobileFormsAuthentication
Öznitelikler

Örnekler

Aşağıdaki kod örneğinde login.aspx sayfası gösterilmektedir. Kimlik doğrulaması işlevi kullanılarak ValidateUser doğrulanır. sınıfı, Membership bir veri kaynağıyla iletişim kurmak için üyelik sağlayıcılarını kullanır.

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Web.Mobile" %>

<script runat="server">
private void Login_Click(Object sender, EventArgs e)
{
// Perform Authentication check here by using 
// UserEmail.Value and UserPswd.Value.
    if (Membership.ValidateUser(UserEmail.Text, UserPswd.Text))
    {
        // Set the authorization cookie
        FormsAuthentication.SetAuthCookie(UserEmail.Text, false);
        // Redirect from login page
        MobileFormsAuthentication.RedirectFromLoginPage(UserEmail.Text, true);
    }
    else
    {
        // Notify the user
        lblError.Text = "Login invalid. Please check your credentials";
    }
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <Mobile:Label runat="server">Enter username</Mobile:Label>
        <Mobile:TextBox id="UserEmail" runat="Server"/>
        <Mobile:Label runat="server">Enter password</Mobile:Label>
        <Mobile:TextBox id="UserPswd" runat="Server"/>
        <Mobile:Command ID="Command1" runat="Server" OnClick="Login_Click"  
            SoftkeyLabel="og">Go</Mobile:Command>
        <Mobile:Label runat="server" id="lblError" />
    </mobile:form>
</body>
</html>
<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Web.Mobile" %>

<script runat="server">
    Private Sub Login_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Perform Authentication check here by using 
        ' UserEmail.Value and UserPswd.Value.
        If (Membership.ValidateUser(UserEmail.Text, UserPswd.Text)) Then
            ' Set the authorization cookie
            FormsAuthentication.SetAuthCookie(UserEmail.Text, False)
            ' Redirect from login page
            MobileFormsAuthentication.RedirectFromLoginPage(UserEmail.Text, True)
        Else
            ' Notify the user
            lblError.Text = "Login invalid. Please check your credentials"
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <Mobile:Label ID="Label1" runat="server">Enter username</Mobile:Label>
        <Mobile:TextBox id="UserEmail" runat="Server"/>
        <Mobile:Label ID="Label2" runat="server">Enter password</Mobile:Label>
        <Mobile:TextBox id="UserPswd" runat="Server"/>
        <Mobile:Command ID="Command1" runat="Server" OnClick="Login_Click"  
            SoftkeyLabel="og">Go</Mobile:Command>
        <Mobile:Label runat="server" id="lblError" />
    </mobile:form>
</body>
</html>

Açıklamalar

Bu yardımcı sınıfı, kimliği doğrulanmış mobil Web siteleri yazma konusunda yardımcı olmak üzere tasarlanmıştır. Sınıf nesneleri, ASP.NET FormsAuthentication sınıfı yöntemlerinin RedirectFromLoginPage ve SignOutmobil cihaz uyumlu sürümlerini sağlar. Web uygulamanızın güvenliğini sağlama hakkında daha fazla bilgi için bkz. Web Uygulamaları için Temel Güvenlik Uygulamaları.

Yöntemler

Equals(Object)
Geçersiz.

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()
Geçersiz.

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()
Geçersiz.

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
MemberwiseClone()
Geçersiz.

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
RedirectFromLoginPage(String, Boolean)
Geçersiz.

Kimliği doğrulanmış bir kullanıcıyı oturum açtıktan sonra başlangıçta istenen URL'ye yönlendirir. Bu, API artık kullanılmıyor. ASP.NET mobil uygulama geliştirme hakkında bilgi için bkz. ASP.NET ile Mobile Apps & Siteleri.

RedirectFromLoginPage(String, Boolean, String)
Geçersiz.

Kimliği doğrulanmış bir kullanıcıyı oturum açtıktan sonra başlangıçta istenen URL'ye yönlendirir. Bu, API artık kullanılmıyor. ASP.NET mobil uygulama geliştirme hakkında bilgi için bkz. ASP.NET ile Mobile Apps & Siteleri.

SignOut()
Geçersiz.

SignOut() yöntemini çağırır ve özelliğini olarak falseayarlarPersistCookielessData. Bu, API artık kullanılmıyor. ASP.NET mobil uygulama geliştirme hakkında bilgi için bkz. ASP.NET ile Mobile Apps & Siteleri.

ToString()
Geçersiz.

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır

Ayrıca bkz.