Aracılığıyla paylaş


MobileFormsAuthentication.RedirectFromLoginPage Yöntem

Tanım

Kimliği doğrulanmış bir kullanıcıyı özgün olarak istenen URL'ye yeniden 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.

Aşırı Yüklemeler

RedirectFromLoginPage(String, Boolean)

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)

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)

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.

public:
 static void RedirectFromLoginPage(System::String ^ userName, bool createPersistentCookie);
public static void RedirectFromLoginPage (string userName, bool createPersistentCookie);
static member RedirectFromLoginPage : string * bool -> unit
Public Shared Sub RedirectFromLoginPage (userName As String, createPersistentCookie As Boolean)

Parametreler

userName
String

Tanımlama bilgisi kimlik doğrulaması amacıyla kullanıcının adı. Bunun bir hesap adıyla eşlemesi gerekmez ve URL Yetkilendirmesi tarafından kullanılır.

createPersistentCookie
Boolean

Dayanıklı bir tanımlama bilgisinin (oturum tabanlı olan veya oturumu dışlayan) verilmesi gerekip gerekmediğini belirtir.

Örnekler

Aşağıdaki örnek, kimliği doğrulanmış bir kullanıcıyı başlangıçta istenen URL'ye göndermek için yöntemini kullanır RedirectFromLoginPage .

<%@ 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

Yöntemler, kimlik doğrulama tanımlama bilgisinden şifrelenmiş bir dize oluşturur ve bunu kaynak isteğin yeniden yönlendirme URL'sine ekler. Ardından bu URL için bir istemci tarafı yeniden yönlendirmesi verilir. Bu, tanımlama bilgilerini desteklemeyen veya kimlik doğrulama bilgilerini güvenli bir şekilde depolamak için çok küçük olan tanımlama bilgilerini destekleyen bazı mobil cihazların sınırlamalarını geçici olarak çözmek için kullanılabilir.

Ayrıca bkz.

Şunlara uygulanır

RedirectFromLoginPage(String, Boolean, String)

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.

public:
 static void RedirectFromLoginPage(System::String ^ userName, bool createPersistentCookie, System::String ^ strCookiePath);
public static void RedirectFromLoginPage (string userName, bool createPersistentCookie, string strCookiePath);
static member RedirectFromLoginPage : string * bool * string -> unit
Public Shared Sub RedirectFromLoginPage (userName As String, createPersistentCookie As Boolean, strCookiePath As String)

Parametreler

userName
String

Tanımlama bilgisi kimlik doğrulaması amacıyla kullanıcının adı. Bunun bir hesap adıyla eşlemesi gerekmez ve URL Yetkilendirmesi tarafından kullanılır.

createPersistentCookie
Boolean

Dayanıklı bir tanımlama bilgisinin (oturum tabanlı olan veya oturumu dışlayan) verilmesi gerekip gerekmediğini belirtir.

strCookiePath
String

Geçerli uygulama için kullanılan yapılandırılmış tanımlama bilgisi yolunu döndürür.

Örnekler

Aşağıdaki örnekte, kimliği doğrulanmış kullanıcıyı başlangıçta istenen URL'ye geri göndermek için yönteminin nasıl kullanılacağı RedirectFromLoginPage gösterilmektedir.

<%@ 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

Yöntemler, kimlik doğrulama tanımlama bilgisinden şifrelenmiş bir dize oluşturur ve bunu kaynak isteğin yeniden yönlendirme URL'sine ekler. Ardından bu URL için bir istemci tarafı yeniden yönlendirmesi verilir. Bu, tanımlama bilgilerini desteklemeyen veya kimlik doğrulama bilgilerini güvenli bir şekilde depolamak için çok küçük olan tanımlama bilgilerini destekleyen bazı mobil cihazların sınırlamalarını geçici olarak çözmek için kullanılabilir.

Ayrıca bkz.

Şunlara uygulanır