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 7051797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:18:24+00:00 2026-05-28T03:18:24+00:00

I am working on creating a custom membership class for my asp.net project. In

  • 0

I am working on creating a custom membership class for my asp.net project. In the MembershipProvider class, function for user validation is defined as follows.

public abstract bool ValidateUser(string username, string password);

The problem is validation can be failed for several reason, so I want to provide more detailed description as to why login failed (e.g., user is lockedout etc) but that cannnot be done via a bool return type. I certainly can create one of my method for validation as follows

public RichStatusDetailsEnum ValidateUser(string username, string password);

Problem with above is that I will not be able to call this method in a generic way (just by Membership.ValidateUser). Rather I will have to instantiate object of my custom membership provider etc etc. Does anyone else has encountered same issue and if there are any better ways of handling this type of situation?

  • 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-28T03:18:24+00:00Added an answer on May 28, 2026 at 3:18 am

    Description

    One way to get this done is

    • Store the reason, why the validation failed, in the HttpContext.Current.Items Collection
    • If ValidateUser failed, get the data and do something (like add an error to ModelState.AddModelError("Property","Message");

    Sample

    public override bool ValidateUser(string username, string password)
    {
        // your custom logic goes here
        HttpContext.Current.Items["ValidateUserResult"] = ValidateUserFailed.UserNameWasWrong;
        return false;
    }
    
    public enum ValidateUserFailed
    {
        UserNameWasWrong, PasswordWasWrong, BecauseIDontLikeYou
    }
    

    your other class

    More Information

    • MSDN – HttpContext.Items Property
    • MSDN – ViewDataDictionary.ModelState Property
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on creating a new base class for an asp.net app in order
I was working on creating a reusable custom control (not a user control) in
I'm working on creating a custom dialog to get input from the user. I've
I'm working on creating an async handler for ASP.NET that will execute a slow
I'm working on a project that involves creating a custom graphical editor. The graphical
i am working in creating a custom class which is subclass of UIWebview. But
I am new to Spring Security. I have been working on creating a custom
I have a simple create user wizard and custom membership provider which was taken
I am working on creating a custom form designer in the Delphi IDE. I'm
I'm working on creating a custom homepage in Drupal. What would be the best

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.