0

我一直在寻找几个小时来解决这个问题。似乎很多人都有类似的问题,但没有一个解决方案对我有用。我需要获取用户名才能在登录时获取 userIndex。

我正在使用默认登录页面:

%@ Page Title="Log In" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Login.aspx.cs" Inherits="LunchTogether.Account.Login" %>
<h2>
        Log In
    </h2>
    <p>
        Please enter your username and password.
        <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink>
        if you don't have an account.
    </p>
    <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false"         LoggedIn="OnLoggedIn" >

后面的代码是:

  void OnLoggedIn(object sender, EventArgs e)
        {
            bool Authenticated = false;
            Authenticated = SiteSpecificAuthenticationMethod(LoginUser.UserName, LoginUser.Password);
        }

我已经尝试了登录控件列出的所有事件,但没有一个事件触发事件。我在这里缺少什么吗?

4

1 回答 1

0

我相信这是因为您必须在创建自己的登录控件版本后覆盖“onLoggedIn”方法。

请参阅此示例: http: //msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.onloggedin (v=vs.100).aspx

我相信您可以使用一些方法,例如:

protected void OnLoginIn(object sender, EventArgs e)

protected void OnLoginError(object sender, EventArgs e)

没有覆盖控件,但我认为 Context.Profile 在通过它们时没有设置,所以在你需要有关登录用户的信息时,我认为你需要覆盖控件。

于 2014-03-19T15:03:54.550 回答