1

I'm new to the ASP.NET MVC 5 and WebAPI 2 technology. I am currently developing a project for my school. This project will be used on computers or mobile.

I have a Visual Studio solution like this:

  • A project "Web.Front" - ASP.NET MVC 5 - A front website used to describe the project
  • A project "Web.Management" - ASP.NET MVC 5 - The core web application
  • A project "WebApi" - WebAPI 2 project with authentication with individual accounts
  • A project "Models" - Class library - containing my POCO classes for Code First
  • A project "Database" - Class library - containing my DbContext and migrations classes

I am having difficulty understanding how to manage users in this project.

I can create my database of my users, and through Fiddler authenticate and create / manage users in my database.

Now I want to access to my users within my controllers on my project "Web.Management".

When creating it , I chose "Individual accounts" for authentication , so visual studio automatically generated AccountController controller.

I would like to change these methods to query my WebAPI directly .

1) Do you think that the architecture of my solution is correct ? 2) Can you tell me how to change my controller " AccountController " to manage users through the WebAPI ?

Regards !

Guillaume Lujan
  • 79
  • 1
  • 17

1 Answers1

8

I strongly suggest you to watch http://pluralsight.com/training/Courses/TableOfContents/aspdotnet-mvc5-fundamentals

  • I would use EF Code First approach which means your model project will be also your database project.
  • Instead of seperating Front and Management I would use Areas.
  • As long as you don't use your API beside Front and Management (e.g. public API) I wouldn't split the project

so you should end up with 2 projects like below

  • Database/Model Entity Framework 6 Code-First approach
  • WebAPI + areas for WebFront/WebManagement
cilerler
  • 9,010
  • 10
  • 56
  • 91
  • 1
    Not enough people know about areas. Super helpful to use once you get a feel for them! Thanks for the reminder! – Stachu Dec 26 '13 at 21:31
  • @statue and cilerler, I believe you can help me with this issue if you have 30 secs... Thks a lot! http://stackoverflow.com/questions/22401403/add-web-api-to-an-existing-mvc-5-web-application – Luis Gouveia Mar 14 '14 at 10:14