O'Reilly logo

ASP.NET Web API Security Essentials by Rajesh Gunasundaram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining Web API Controllers and methods

So far, we created an empty ASP.NET Web API application. We installed the necessary NuGet packages for ASP.NET Identity and OWIN integration. We also added the code for identity user and db context, and enabled the db migration for the entity framework code first migration. Now let's add the required controllers and methods to manage user accounts in application identity system.

Create a controller named AccountsController and add the following code:

namespace ContactLookupWithAspNetIdentity.Controllers { [RoutePrefix("api/accounts")] public class AccountsController : ApiController { public ApplicationUserManager UserManager { get { return Request.GetOWINContext().GetUserManager<ApplicationUserManager>(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required