1

I'm new to web development. I have a login.aspx page that has an Asp.Net login control on it. When the users logs in and it successfully authenticates, the page automatically redirects to default.aspx. I assume this is some kind of default behavior?

But, I actually need the login information from the login page in default.aspx.cs. How do I get this information from that context?

In addition, I'm not always going to count on the user successfully logging in with the login control-- If I want to redirect to default.aspx without a login event occurring, how can I do that while also passing the login information being used?

4

4 に答える 4

3

呼び出しMembership.GetUser()て、現在ログインしているユーザーを取得できます。

于 2011-07-07T16:24:37.410 に答える
2

ユーザーが認証されてログインされたので、Web アプリのどこでもこの種のことを実行できます。

        MembershipUser mu = Membership.GetUser();

        if (mu.PasswordQuestion == null || mu.PasswordQuestion.Length < 3)
        {
            Response.Redirect("~/Account/ChangePasswordQuestion.aspx");
        }
于 2011-07-07T16:27:45.213 に答える
1

ユーザー名のみを取得する必要がある場合は、次のように取得できます..

HttpContext.Current.User.Identity.Name// it will return current logined username

それ以外の場合は、値をセッション変数に入れてから、デフォルト ページでアクセスできます。

于 2011-07-07T16:25:28.120 に答える
0

LoginViewコントロールを使用する

于 2011-07-07T16:24:37.010 に答える