Authorization has been denied for this request - New Web API Project

前端 未结 4 699
渐次进展
渐次进展 2021-01-30 10:58

I just created new Web API project (using MVC) in visual studio 2015 and for the testing purpose, I ran that project but ended up below error.

After running the project,

4条回答
  •  孤城傲影
    2021-01-30 11:18

    It happens because you have an Authorize attribute on your ValuesController

    [Authorize]
    public class ValuesController : ApiController
    

    Just remove [Authorize] and try again

    EDIT

    According to your edit: You should create a new user and login or use [AllowAnonymous] as mentioned by @Marcus H. Read more about Identity

提交回复
热议问题