Apply [Authorize] attribute implicitly to all Web API controllers

You have two options

  1. Controller level by decorating your controller with authorize attribute.

    [Authorize]
    [RoutePrefix("api/account")]
    public class AccountController : ApiController
    {
    
  2. You can also set it global level to all routes, in Register method of WebApiConfig.cs file

     config.Filters.Add(new AuthorizeAttribute());
    

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)