0

I am in the progress of adding a login system to an ASP.NET MVC5 application (previously MVC4 but converted to MVC5) and am having trouble with the conflicting and confusing information on adding accounts and roles to a website. I do not have an option to open the Web Site Administration Tool (neither under Website or Project) and the template confuses me in where the accounts are stored.

I'm expecting high loads as these accounts will also be used via a WebAPI to generate session keys for authentication on multiplayer servers in a game. The accounts will also be used to allow administrators to update information on the site. I didn't yet look at ASP.NET Identity but with the hours I've already sunken into this I'm a bit reluctant to look at it if it's going to be another dead end.

I'm using a model-first EDMX file for connecting to the database which is located in a separate project which also contains a collection of helper classes for contacting the database.

Layl Conway
  • 385
  • 9
  • 17

3 Answers3

0

I'm not sure why you upgraded your project for a reason other than the new provider??

Identity is definitely not a dead end. It's much easier to use than the previous membership provider once you move past the ever so small learning curve. In a sense Identity is also model first. I know you already have some time sunk into this project already but I think moving to ASP Identity will be time well spent if you are going to continue to support the application.

This is how I might go about it.

  1. Create a new MVC5 project.
  2. Open > ServerExplorer
  3. Get the location of the public class ApplicationUser : IdentityUser. It's the 'DefaultConnection' in the root Web.Config.
  4. Import the data from the old Asp membership provider and match the appropriate fields.
  5. Fields that do not exist can be created in the IdentityModels.cs > public class ApplicationUser : IdentityUser
stink
  • 865
  • 8
  • 19
0

After trying out implementing my own custom Membership Provider, this ended up being the most simple and quick way to do it. I followed the guide here and got it running with in half a hour against my existing database: http://theintegrity.co.uk/2010/11/asp-net-mvc-2-custom-membership-provider-tutorial-part-1/ After this was working, adding a custom roles provider was just as easy.

Layl Conway
  • 385
  • 9
  • 17
0

You can add Roles to the ASP.NET Identity System and use the [Authorize] attribute to Authorize access to parts of your website. You can look at the following post which explains how you can add roles and add users to roles and restrict access to certain users in roles http://blogs.msdn.com/b/webdev/archive/2013/10/20/building-a-simple-todo-application-with-asp-net-identity-and-associating-users-with-todoes.aspx At this point we do not have a website admin tool so you will have to create Roles in your application

pranav rastogi
  • 4,124
  • 23
  • 23