Search code examples
c#asp.net-web-apiauthorizesystem.web.http

Remove Authorize rule for specific API call


I have a WEB Api controller, that has the [Authorize] tag at the top of the controller - which means all API in this class will have this rule applied. Like this:

    [Authorize]
    [RoutePrefix("api/v1/route")]
        public class ItemController : ApiController
    {
/// Etc...

My issue is that for a specific call within this class, I do not want this Auth rule to apply. I am sure I have seen a way of doing this before, but for all my googling I cannot find it. I think it is something like this:

        [HttpPost]
        [Route("singleCall")]
        [NOTAUTH]//whatever should go in here
        public void Log()
        {

Any ideas???


Solution

  • Take a look at [AllowAnonymous].

    This page has some examples.