Login.Password プロパティ

定義

ユーザーが入力したパスワードを取得します。

public:
 virtual property System::String ^ Password { System::String ^ get(); };
[System.ComponentModel.Browsable(false)]
public virtual string Password { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Password : string
Public Overridable ReadOnly Property Password As String

プロパティ値

ユーザーが入力したパスワード。 既定値は、null です。

属性

次のコード例では、 プロパティを Password カスタム認証方法に渡します。

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
private bool SiteSpecificAuthenticationMethod(string UserName, string Password)
{
    // Insert code that implements a site-specific custom 
    // authentication method here.
    //
    // This example implementation always returns false.
    return false;
}

private void OnAuthenticate(object sender, AuthenticateEventArgs e)
{
    bool Authenticated = false;
    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password);

    e.Authenticated = Authenticated;
}

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server"
                OnAuthenticate="OnAuthenticate">
            </asp:Login>
        </form>
    </body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Function SiteSpecificAuthenticationMethod(ByVal UserName As String, ByVal Password As String) As Boolean
    ' Insert code that implements a site-specific custom 
    ' authentication method here.
    '
    ' This example implementation always returns false.
    Return False
End Function

Sub OnAuthenticate(ByVal sender As Object, ByVal e As AuthenticateEventArgs)
    Dim Authenticated As Boolean
    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password)

    e.Authenticated = Authenticated
End Sub


</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server"
                OnAuthenticate="OnAuthenticate">
            </asp:Login>

        </form>
    </body>
</html>

注釈

Passwordプロパティには、ユーザーが入力したパスワードが含まれます。 パスワードはクリア テキストです。 詳細については、「 Web アプリケーションの基本的なセキュリティ プラクティス」を参照してください。

Note

または Password プロパティをUserNameプログラムで操作する場合は、ページライフ サイクル中に正しいタイミングで操作することが重要です。 と のUserName値はフェーズ中Page_Loadは使用できませんが、フェーズ中ですPre_RenderPassword

LoginPasswordなどのUserNameテキスト ボックスで表されるコントロール プロパティは、ページ ライフ サイクルのすべてのフェーズでアクセスできます。 コントロールは、テキスト ボックスによってトリガーされるイベントによって TextChanged 、エンド ユーザーによって行われた変更を取得します。

適用対象

こちらもご覧ください