I have used the default web application template for ASP.NET Core and created an application (http://localhost:xxxx/).
Now I have added a new Web API Controller with path as api/test
and default get method that returns a test string array and have decorated the API with Authorize
attribute.
Now I have run the application and logged in with registered user.
Opened fiddler and tried to access the web API (http://localhost:xxxx/api/test/).
But it's redirecting me to login page. I have tried using the cookie authentication too but still not able to access Web API. Am I missing something here?
[Route("api/test")]
[Authorize]
public class TestController : Controller
{
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
}