Search code examples
model-view-controllerauthorize-attribute

MVC AuthorizeAttribute Class and exsiting table


I have an exsiting MVC project(I'm new to MVC), and now I need to add a Login section. I already have a table with users and passwords, that I need to use them.

How can I combine the two, by using AuthorizeAttribute Class? I already using the DB (with a connectionString) and everything works perfectly, I just can't realize how to "tell" the AccountController to work with a specific table in my DB.

Any help will be appriciated!


Solution

  • Got it. On Global.asax:

    WebSecurity.InitializeDatabaseConnection("ConnectionString", "tableName", "Id", "UserName", autoCreateTables: true);