I am having trouble displaying the username after login on my index page.
The code I have for Logging in:
protected void btnLoginButton_Click(object send
You simply forgot to actually login your user. All you do is validating the users credentials and then do a redirect. So try to add the following line in your if-statement:
protected void LoginButton_Click(object sender, EventArgs e)
{
// Validate the user against the Membership framework user store
if (Membership.ValidateUser(UserName.Text, Password.Text))
{
// Log the user into the site
FormsAuthentication.SetAuthCookie(UserName.Text, true);
// Do the redirect
Response.Redirect("~/Index.aspx");
}
// If we reach here, the user's credentials were invalid
InvalidCredentialsMessage.Visible = true;
}
protected void btnLoginButton_Click(object sender, EventArgs e)
{
if (Membership.ValidateUser(UserName.Text, Password.Text))
{
WelcomeBackMessage.Text = User.Identity.Name.ToString();
// Log the user into the site
Response.Redirect("~/Index.aspx");
Place WelcomeBackMessage label in master page and try this code.