Get Started with Azure Active Directory (WebApi projects)

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

This article provides additional guidance after you've added Active Directory to an ASP.NET WebAPI project through the Project > Connected Services command of Visual Studio. If you've not already added the service to your project, you can do so at any time.

See What happened to my WebAPI project? for the changes made to your project when adding the connected service.

Requiring authentication to access controllers

All controllers in your project were adorned with the [Authorize] attribute. This attribute requires the user to be authenticated before accessing the APIs defined by these controllers. To allow the controller to be accessed anonymously, remove this attribute from the controller. If you want to set the permissions at a more granular level, apply the attribute to each method that requires authorization instead of applying it to the controller class.