MobileFormsAuthentication.RedirectFromLoginPage Metodo

Definizione

Reindirizza un utente autenticato all'URL richiesto originariamente. Questa API è obsoleta. Per informazioni su come sviluppare applicazioni ASP.NET per dispositivi mobili, vedere App per dispositivi mobili & Siti con ASP.NET.

Overload

RedirectFromLoginPage(String, Boolean)

Reindirizza un utente autenticato all'URL richiesto originariamente dopo la connessione. Questa API è obsoleta. Per informazioni su come sviluppare applicazioni ASP.NET per dispositivi mobili, vedere App per dispositivi mobili & Siti con ASP.NET.

RedirectFromLoginPage(String, Boolean, String)

Reindirizza un utente autenticato all'URL richiesto originariamente dopo la connessione. Questa API è obsoleta. Per informazioni su come sviluppare applicazioni ASP.NET per dispositivi mobili, vedere App per dispositivi mobili & Siti con ASP.NET.

RedirectFromLoginPage(String, Boolean)

Reindirizza un utente autenticato all'URL richiesto originariamente dopo la connessione. Questa API è obsoleta. Per informazioni su come sviluppare applicazioni ASP.NET per dispositivi mobili, vedere App per dispositivi mobili & Siti con 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)

Parametri

userName
String

Nome dell'utente per l'autenticazione del cookie. Non è necessario che sia associato a un nome account ed è utilizzato dall'autorizzazione URL.

createPersistentCookie
Boolean

Specifica se emettere un cookie permanente, ovvero un cookie basato sulla sessione o che duri oltre la fine della sessione.

Esempio

Nell'esempio seguente viene usato il RedirectFromLoginPage metodo per inviare un utente autenticato all'URL originariamente richiesto.

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

Commenti

I metodi creano una stringa crittografata dal cookie di autenticazione e la aggiungono all'URL di reindirizzamento della richiesta di origine. Viene quindi generato un reindirizzamento sul lato client per tale URL. Può essere usato per aggirare le limitazioni di determinati dispositivi mobili che non supportano i cookie o supportano cookie troppo piccoli per archiviare le informazioni di autenticazione in modo sicuro.

Vedi anche

Si applica a

RedirectFromLoginPage(String, Boolean, String)

Reindirizza un utente autenticato all'URL richiesto originariamente dopo la connessione. Questa API è obsoleta. Per informazioni su come sviluppare applicazioni ASP.NET per dispositivi mobili, vedere App per dispositivi mobili & Siti con 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)

Parametri

userName
String

Nome dell'utente per l'autenticazione del cookie. Non è necessario che sia associato a un nome account ed è utilizzato dall'autorizzazione URL.

createPersistentCookie
Boolean

Specifica se emettere un cookie permanente, ovvero un cookie basato sulla sessione o che duri oltre la fine della sessione.

strCookiePath
String

Restituisce il percorso del cookie configurato utilizzato per l'applicazione corrente.

Esempio

Nell'esempio seguente viene illustrato come usare il RedirectFromLoginPage metodo per inviare di nuovo l'utente autenticato all'URL richiesto in 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>

Commenti

I metodi creano una stringa crittografata dal cookie di autenticazione e la aggiungono all'URL di reindirizzamento della richiesta di origine. Viene quindi generato un reindirizzamento sul lato client per tale URL. Può essere usato per aggirare le limitazioni di determinati dispositivi mobili che non supportano i cookie o supportano cookie troppo piccoli per archiviare le informazioni di autenticazione in modo sicuro.

Vedi anche

Si applica a