<asp login =“”> control,无法找到使用此控件设置用户名和密码的位置</asp>

时间:2012-09-27 06:55:13

标签: c# asp.net .net

我正在开发一个已经构建并正常运行的项目。我现在需要做的是用salt加密密码。通常我可以做到这一切,但是我很难看到控件asp的位置:登录获取用户名和密码。我搜索了整个项目,无法找到从数据库中检索用户名和密码的位置以及检查它是否正确的位置。这里是标记:

   <asp:Login ID="LoginUser" runat="server" EnableViewState="False" RenderOuterTable="False" OnLoggingIn="LoginUser_LoggingIn">
    <LayoutTemplate>
        <div class="accountInfo">
            <fieldset class="Login">
                <p>
                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" CssClass="text"></asp:Label>
                    <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                        CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required."
                        ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                </p>
                <p>
                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" CssClass="text"></asp:Label>
                    <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                        CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
                        ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                </p>
            </fieldset>
            <span class="error">
                <asp:Literal ID="FailureText" runat="server"></asp:Literal>
            </span>
            <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="error"
                ValidationGroup="LoginUserValidationGroup" />
            <p class="submitButton">
                <asp:Button CssClass="submitButton" ID="LoginButton" runat="server" CommandName="Login"
                    ValidationGroup="LoginUserValidationGroup" Text="d" OnClick="LoginButton_Click" />
            </p>
        </div>
    </LayoutTemplate>
</asp:Login>

以下是代码隐藏:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mycompany.BaseCode;
using System.Threading;

namespace mycompany.Account
{
    public partial class Login : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(SessionManager.Culture);

        lblLoginTitle.Text = Resources.Login.LoginTitle;
        lblExtraInfo.Text = Resources.Login.ExtraInfo;

        var llb = (Label)LoginUser.FindControl("UserNameLabel");
        llb.Text = Resources.Login.Username;
        llb = (Label)LoginUser.FindControl("PasswordLabel");
        llb.Text = Resources.Login.Password;

        LoginUser.FailureText = Resources.Login.FailureText;

        var rfv = (RequiredFieldValidator)LoginUser.FindControl("PasswordRequired");
        rfv.ErrorMessage = Resources.Login.PasswordRequired;
        rfv = (RequiredFieldValidator)LoginUser.FindControl("UserNameRequired");
        rfv.ErrorMessage = Resources.Login.UsernameRequired;

        var btn = (Button)LoginUser.FindControl("LoginButton");
        btn.Text = Resources.Login.btnLogin;

    }
}
}

在任何地方都找不到OnLoggingIn =“LoginUser_LoggingIn”或OnClick =“LoginButton_Click”事件。我甚至查看了基本代码。有趣的是它正在工作。 任何有关在何处找到这些隐藏细节的解释或提示都将深受赞赏

1 个答案:

答案 0 :(得分:1)

如果您没有任何事件处理程序,它将使用您在web.config中配置的默认MembershipProvider

如果您还没有配置MembershipProvider,我认为您至少需要处理Login.Authenticate事件。