MobileFormsAuthentication.RedirectFromLoginPage Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mengalihkan pengguna terautentikasi kembali ke URL yang awalnya diminta. API ini kedaluarsa. Untuk informasi tentang cara mengembangkan aplikasi seluler ASP.NET, lihat Situs & Mobile Apps dengan ASP.NET.
Overload
| RedirectFromLoginPage(String, Boolean) |
Mengalihkan pengguna terautentikasi ke URL yang awalnya diminta setelah masuk. API ini kedaluarsa. Untuk informasi tentang cara mengembangkan aplikasi seluler ASP.NET, lihat Situs & Mobile Apps dengan ASP.NET. |
| RedirectFromLoginPage(String, Boolean, String) |
Mengalihkan pengguna terautentikasi ke URL yang awalnya diminta setelah masuk. API ini kedaluarsa. Untuk informasi tentang cara mengembangkan aplikasi seluler ASP.NET, lihat Situs & Mobile Apps dengan ASP.NET. |
RedirectFromLoginPage(String, Boolean)
Mengalihkan pengguna terautentikasi ke URL yang awalnya diminta setelah masuk. API ini kedaluarsa. Untuk informasi tentang cara mengembangkan aplikasi seluler ASP.NET, lihat Situs & Mobile Apps dengan 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)
Parameter
- userName
- String
Nama pengguna untuk tujuan autentikasi cookie. Ini tidak perlu memetakan ke nama akun dan digunakan oleh Otorisasi URL.
- createPersistentCookie
- Boolean
Menentukan apakah cookie tahan lama atau tidak (cookie yang berbasis sesi atau lebih lama dari sesi) harus dikeluarkan.
Contoh
Contoh berikut menggunakan RedirectFromLoginPage metode untuk mengirim pengguna yang diautentikasi ke URL yang awalnya diminta.
<%@ 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>
Keterangan
Metode membuat string terenkripsi dari cookie autentikasi dan menambahkannya ke URL pengalihan permintaan asal. Pengalihan sisi klien kemudian dikeluarkan untuk URL tersebut. Ini dapat digunakan untuk mengatasi batasan perangkat seluler tertentu yang tidak mendukung cookie, atau mendukung cookie yang terlalu kecil untuk menyimpan informasi autentikasi dengan cara yang aman.
Lihat juga
Berlaku untuk
RedirectFromLoginPage(String, Boolean, String)
Mengalihkan pengguna terautentikasi ke URL yang awalnya diminta setelah masuk. API ini kedaluarsa. Untuk informasi tentang cara mengembangkan aplikasi seluler ASP.NET, lihat Situs & Mobile Apps dengan 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)
Parameter
- userName
- String
Nama pengguna untuk tujuan autentikasi cookie. Ini tidak perlu memetakan ke nama akun dan digunakan oleh Otorisasi URL.
- createPersistentCookie
- Boolean
Menentukan apakah cookie tahan lama atau tidak (cookie yang berbasis sesi atau lebih lama dari sesi) harus dikeluarkan.
- strCookiePath
- String
Mengembalikan jalur cookie yang dikonfigurasi yang digunakan untuk aplikasi saat ini.
Contoh
Contoh berikut menunjukkan cara menggunakan RedirectFromLoginPage metode untuk mengirim pengguna yang diautentikasi kembali ke URL yang awalnya diminta.
<%@ 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>
Keterangan
Metode membuat string terenkripsi dari cookie autentikasi dan menambahkannya ke URL pengalihan permintaan asal. Pengalihan sisi klien kemudian dikeluarkan untuk URL tersebut. Ini dapat digunakan untuk mengatasi batasan perangkat seluler tertentu yang tidak mendukung cookie, atau mendukung cookie yang terlalu kecil untuk menyimpan informasi autentikasi dengan cara yang aman.