Search code examples
asp.netasp.net-mvcasp.net-mvc-4membership

what is the best practice for implementing only one user (Admin) in mvc 4 web application


I want my website to be seen by anonymous users. and i don't want it to have a login /register user part. i just need one user as administrator and its username and password is chosen manually. what is the best practice to implement this login part (website has only one user for ever). my question is how to implement this one user login part, where store username and password and does it need a table in database?


Solution

  • For me - if you're having such a simple system, then merely storing the username / pwd in the web.config is fine.

    I'd create a helper class to wrap up talking to the config file (ConfigurationManager.AppSettings on MSDN) and use and evaluate a simple "logon" action.

    No table needed.

    Finally - make sure you add the AuthoriseAttribute to your controller that will be doing the admin actions...

    HTH