Partager via


MobileFormsAuthentication.RedirectFromLoginPage Méthode

Définition

Redirige un utilisateur authentifié vers l'URL demandée à l'origine. Cette API est obsolète. Pour plus d’informations sur le développement d’applications mobiles ASP.NET, consultez Mobile Apps & Sites avec ASP.NET.

Surcharges

RedirectFromLoginPage(String, Boolean)

Redirige un utilisateur authentifié vers l'URL demandée à l'origine, une fois la connexion établie. Cette API est obsolète. Pour plus d’informations sur le développement d’applications mobiles ASP.NET, consultez Mobile Apps & Sites avec ASP.NET.

RedirectFromLoginPage(String, Boolean, String)

Redirige un utilisateur authentifié vers l'URL demandée à l'origine, une fois la connexion établie. Cette API est obsolète. Pour plus d’informations sur le développement d’applications mobiles ASP.NET, consultez Mobile Apps & Sites avec ASP.NET.

RedirectFromLoginPage(String, Boolean)

Redirige un utilisateur authentifié vers l'URL demandée à l'origine, une fois la connexion établie. Cette API est obsolète. Pour plus d’informations sur le développement d’applications mobiles ASP.NET, consultez Mobile Apps & Sites avec ASP.NET.

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)

Paramètres

userName
String

Nom de l'utilisateur pour l'authentification des cookies. Il n'a pas besoin de correspondre à un nom de compte et est utilisé par l'autorisation d'URL.

createPersistentCookie
Boolean

Spécifie si un cookie persistant (c'est-à-dire un cookie basé sur une session ou lui survivant) doit être ou non émis.

Exemples

L’exemple suivant utilise la RedirectFromLoginPage méthode pour envoyer un utilisateur authentifié à l’URL initialement demandée.

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

Remarques

Les méthodes créent une chaîne chiffrée à partir du cookie d’authentification et l’ajoutent à l’URL de redirection de la demande d’origine. Une redirection côté client est ensuite émise pour cette URL. Cela peut être utilisé pour contourner les limitations de certains appareils mobiles qui ne prennent pas en charge les cookies ou qui prennent en charge les cookies trop petits pour stocker les informations d’authentification de manière sécurisée.

Voir aussi

S’applique à

RedirectFromLoginPage(String, Boolean, String)

Redirige un utilisateur authentifié vers l'URL demandée à l'origine, une fois la connexion établie. Cette API est obsolète. Pour plus d’informations sur le développement d’applications mobiles ASP.NET, consultez Mobile Apps & Sites avec ASP.NET.

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)

Paramètres

userName
String

Nom de l'utilisateur pour l'authentification des cookies. Il n'a pas besoin de correspondre à un nom de compte et est utilisé par l'autorisation d'URL.

createPersistentCookie
Boolean

Spécifie si un cookie persistant (c'est-à-dire un cookie basé sur une session ou lui survivant) doit être ou non émis.

strCookiePath
String

Retourne le chemin d'accès de cookie configuré utilisé pour l'application actuelle.

Exemples

L’exemple suivant montre comment utiliser la RedirectFromLoginPage méthode pour renvoyer l’utilisateur authentifié à l’URL demandée à l’origine.

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

Remarques

Les méthodes créent une chaîne chiffrée à partir du cookie d’authentification et l’ajoutent à l’URL de redirection de la demande d’origine. Une redirection côté client est ensuite émise pour cette URL. Cela peut être utilisé pour contourner les limitations de certains appareils mobiles qui ne prennent pas en charge les cookies ou qui prennent en charge les cookies trop petits pour stocker les informations d’authentification de manière sécurisée.

Voir aussi

S’applique à