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

  • Home
  • SEARCH
  • 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 3636616
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:03:20+00:00 2026-05-19T01:03:20+00:00

can you help me with my problem: i have ASP.NET web site that have

  • 0

can you help me with my problem:

i have ASP.NET web site that have some basic authorization features (Login/Logoout e.t.c.). Currently i have 3 main methods:

  • bool Login(string name, string password);
  • bool IsLogged();
  • string GetUserID();

All this methods are “hardcoded” into one class. Login methods checks database to determine that user exists. But then I’ve decided to use XML file to store users, it means that all logic that checked a user should be rewritten.

I’ve got an idea to use the following “pattern”:

  1. Create interface (e.g. ILoginProvider) that declares those 3 methods that described above
  2. Implement this interface in any class and write specific logic in Login() method to check XML file or database
  3. Pass this class to ??? (here is my problem)

I thought to make a class (e.g. LoginHelper) that can take ILoginProvider interface as an argument:

class LoginHelper {

    private static ILoginProvider provider;

    // this method should be called somewhere in Application_Startup event in Global.asax
    public static void RegisterLoginProvider(ILoginProvider inst) {
        provider = inst; 
    }
}

and then write necessary methods:

public static bool IsLogged() {
    return provider.IsLogged();
}

and then call RegisterLoginProvider() method in Global.asax in Application_Startup event:

MyCustomProvider prov = new MyCustomProvider(); // this class implements ILoginProvider interface
LoginHelper.RegisterSecurityProvider(prov);

Is it a correct way to implement such logic to change some “providers” with others?

  • 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-19T01:03:21+00:00Added an answer on May 19, 2026 at 1:03 am

    The way this is often done is via a service locator (Unity, StructureMap etc) or a custom factory where you ask for an instance of ILoginProvider and the correct one is returned.

    The responsibility of selecting which kind of ILoginProvider to create is not up to the calling class.

    //get a login provider from via a service locator
    ILoginProvider provider = DependencyLookup.Resolve<ILoginProvider>();
    

    With the service locators, you would register against ILoginProvider which implementation to use, either in XML configuration or in code. Here is an example for Unity.

    public static class ContainerConfiguration
    {
        public static void Configure()
        {
            ServiceLocator.Current.RegisterType<ILoginProvider, XmlLoginProvider>();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a asp.net web application, that allows users to login and logout. When
I have a problem with preg_match_all that maybe you can help. I have a
I hope some of you guys can help me with this problem.... I have
I hope someone can help with solution to this problem? Currently my ASP.Net MVC
My setup: ASP.NET 4.0 Web Site running on IIS 6.0. I have a site
I'm trying to develop my first site in ASP.Net using Web Forms. I have
I have a Master page in my ASP.net web site. And here I have
I have an existing ASP.NET web application that I'm converting to MVC 1.0. The
I have an asp.net c# website that I am having a problem getting the
can anyone help, i have problem doing a sort, I thought i had it

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.