Can I use the .NET MembershipProvider to create multiple virtual "applications" in a single web application?

I want to create a web application with an asp.net website from scratch, and considered the asp.net MembershipProvider as a standard way to manage users. I created my own provider inheriting from SqlMembershipProvider and overriding the ValidateUser method:

        public override bool ValidateUser(string username, string password)
        {
            string temp = ApplicationName;
            List<MtscApp> allApps = GetAllApplications();
            foreach (MtscApp app in allApps)
            {
                ApplicationName = app.Name;
                Roles.ApplicationName = app.Name;
                if (base.ValidateUser(username, password))
                {
                    return true;
                }
            }
            ApplicationName = temp;
            Roles.ApplicationName = temp;
            return false;
        }

      

I am trying to validate entered credentials for all applications and GetAllApplicationsMethod () gets all applications from the aspnet_Applications table (I also have a part for inserting applications into the same table).

If validation is successful, then the application name is issued for both membership providers and roles, otherwise it remains on the default, which is a predefined application for anonymous users.

+1


source to share


1 answer


Yes, I have done this several times. The only difference is that I am looking at the application name in the database table based on the URL, which the user disconnects and checks for that application only. The table has two fields: URL and ApplicationName. The application name is the same application name as the aspnet_Applications.ApplicationName field.



+1


source







All Articles