+ Reply to Thread
Results 1 to 2 of 2

Thread: Return message to user

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    15

    Return message to user

    Hi i am creating a logon form and i want to display "Your Account is Locked!" message for the SqlMembershipProvider in MVC2
    my code looks like that :
    Code:
    [RequireHttps]
    [HttpPost]
    public ActionResult LogOn(LogOnModel model, string returnUrl)
    {
          if (ModelState.IsValid)
          {
                    if (MembershipService.ValidateUser(model.UserName, model.Password))
                    {
                         FormsService.SignIn(model.UserName, model.RememberMe);
    
                         UserProfile profile = UserProfile.GetUserProfile(model.UserName);
                    }
                    else
                    {
                         ModelState.AddModelError("", "invalid username or password.");
                    }
            }
       }
    
       return View(model);
    }
    Last edited by osource; 01-26-2012 at 04:27 PM.

  2. #2
    Why don`t you use the membershipuser , try the below code :
    Code:
    MembershipUser user = Membership.GetUser("Username")
    
    if (user != null && user.IsLockedOut)
    {
        return View("You got locked Out");
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts