Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7162481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:44:31+00:00 2026-05-28T13:44:31+00:00

I have to implement Your Account is Locked! message for the SqlMembershipProvider in MVC2

  • 0

I have to implement “Your Account is Locked!” message for the SqlMembershipProvider in MVC2 project.

How I can do it?

Basically my code to logon looks like:

[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("", "The user name or password provided is incorrect.");
        }
   }

   return View(model);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:44:32+00:00Added an answer on May 28, 2026 at 1:44 pm

    Is it just like normal membership?

    MembershipUser user = Membership.GetUser("Username")
    
    if (user != null && user.IsLockedOut)
    {
        return View("YourPasswordIsTooAmbiguousSoYouGotLockedOut");
    }
    

    MSDN: Membership.GetUser(string username)

    –Side Note–

    The order in which you do authentication is really a Security & UX thing. I’d suggest the following pseudo-code (but I’m no expert):

    public ActionResult LogOn(LogOnModel model)
    {
        // Is model valid?
        if (!ModelState.IsValid)
        {
            this.ViewData["LogOnError"] = "Bad Credentials.";
            return this.View(model);
        }
    
        // Is user valid?
        if(!MembershipService.ValidateUser(model.UserName, model.Password))
        {
            this.ViewData["LogOnError"] = "Wrong Credentials.";
            return this.View(model);
        }
    
        MembershipUser user = Membership.GetUser(model.UserName);
    
        // Was the user deleted in the last nano-second?
        if (user == null)
        {
            this.ViewData["LogOnError"] = "Race Condition: User previously deleted.";
            return this.View(model);
        }
    
        // Is user locked out?
        if(user.IsLockedOut)
        {
            this.ViewData["LogOnError"] = "You are locked out.";
            return this.View(model);
        }
    
        // Sign the user in.
        FormsService.SignIn(model.UserName, model.RememberMe);
    
        return this.View("LogOnSuccessful");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have to implement a piece of T-SQL code that must return
I have a school project in which I have to implement a chat application,
I'm currently designing a small website and I'd like to implement the forgot your
I'm working on a multi-user, multi-account App where 1 account can have n users.
The Android developer guide (http://developer.android.com/resources/tutorials/views/hello-tabwidget.html) states: `You can implement your tab content in one
For those of you who have implemented Scrum in your organizations, what were your
I have to implement the VinPower application. They offer a Java version, a C
I have to implement MPI system in a cluster. If anyone here has any
I have to implement a middleware system for file sharing, and it has to
I have to implement a IExceptionHandler for the Enteprise Library 4.1. In my particular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.