Partilhar via


MobileFormsAuthentication.RedirectFromLoginPage Método

Definição

Redireciona um usuário autenticado de volta para a URL solicitada originalmente. Esta API está obsoleta. Para obter informações sobre como desenvolver aplicativos móveis ASP.NET, consulte Aplicativos Móveis & Sites com ASP.NET.

Sobrecargas

RedirectFromLoginPage(String, Boolean)

Redireciona um usuário autenticado para a URL solicitada originalmente após o logon. Esta API está obsoleta. Para obter informações sobre como desenvolver aplicativos móveis ASP.NET, consulte Aplicativos Móveis & Sites com ASP.NET.

RedirectFromLoginPage(String, Boolean, String)

Redireciona um usuário autenticado para a URL solicitada originalmente após o logon. Esta API está obsoleta. Para obter informações sobre como desenvolver aplicativos móveis ASP.NET, consulte Aplicativos Móveis & Sites com ASP.NET.

RedirectFromLoginPage(String, Boolean)

Redireciona um usuário autenticado para a URL solicitada originalmente após o logon. Esta API está obsoleta. Para obter informações sobre como desenvolver aplicativos móveis ASP.NET, consulte Aplicativos Móveis & Sites com 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)

Parâmetros

userName
String

Nome do usuário para fins de autenticação de cookie. Isso não precisa ser mapeado para um nome de conta e é usado por Autorização de URL.

createPersistentCookie
Boolean

Especifica se um cookie durável (baseado em sessão ou que dura mais que a sessão) deve ser emitido ou não.

Exemplos

O exemplo a seguir usa o RedirectFromLoginPage método para enviar um usuário autenticado para a URL solicitada originalmente.

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

Comentários

Os métodos criam uma cadeia de caracteres criptografada do cookie de autenticação e a acrescentam à URL de redirecionamento da solicitação de origem. Um redirecionamento do lado do cliente é emitido para essa URL. Isso pode ser usado para contornar as limitações de determinados dispositivos móveis que não dão suporte a cookies ou dão suporte a cookies muito pequenos para armazenar informações de autenticação de maneira segura.

Confira também

Aplica-se a

RedirectFromLoginPage(String, Boolean, String)

Redireciona um usuário autenticado para a URL solicitada originalmente após o logon. Esta API está obsoleta. Para obter informações sobre como desenvolver aplicativos móveis ASP.NET, consulte Aplicativos Móveis & Sites com 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)

Parâmetros

userName
String

Nome do usuário para fins de autenticação de cookie. Isso não precisa ser mapeado para um nome de conta e é usado por Autorização de URL.

createPersistentCookie
Boolean

Especifica se um cookie durável (baseado em sessão ou que dura mais que a sessão) deve ser emitido ou não.

strCookiePath
String

Retorna o caminho do cookie configurado usado para o aplicativo atual.

Exemplos

O exemplo a seguir demonstra como usar o RedirectFromLoginPage método para enviar o usuário autenticado de volta para a URL que foi originalmente solicitada.

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

Comentários

Os métodos criam uma cadeia de caracteres criptografada do cookie de autenticação e a acrescentam à URL de redirecionamento da solicitação de origem. Um redirecionamento do lado do cliente é emitido para essa URL. Isso pode ser usado para contornar as limitações de determinados dispositivos móveis que não dão suporte a cookies ou dão suporte a cookies muito pequenos para armazenar informações de autenticação de maneira segura.

Confira também

Aplica-se a