I have an MVC applicaton with webapi controller in it.
When user is authenicated he has access to all mvc [Authorize]
controller actions in the application. But for some reason when I set attribute [Authorize]
on WebApi controller that is located on my application authenicated
users cant access to this WebApi actions, server return user 401 Unauthorized
[Authorize]
public class FilesController : ApiController
By researching i found out that [Authorize]
attribute for WebApi is actually System.Web.Http.AuthorizeAttribute
and for mvc controller it is System.Web.Mvc.AuthorizeAttribute
.
Is there any way to setup application the way if user is authorized in the mvc > controller level so he will be authorized for webapi too?
I tried to change the WebApi attribute to [System.Web.Mvc.Authorize]
but it is not seams to be working.
Looks like I have to do something similar to this using this library Do u have any ideas?