Just tried and worked fine. I am sure you have an error in your URL.
Here is my preliminary controller:
[Authorize]
[BreezeController]
public class BreezeTodoController: ApiController
{
private readonly BreezeTodoContext _context;
public BreezeTodoController () {
_context = new BreezeTodoContext (User);
}
[HttpGet]
public string Metadata () {
return _context.Metadata ();
}
// ... more
I hit it with this url
http: // localhost: 32377 / api / breezetodox / metadata
And I will return 401
Request URL: http: // localhost: 32377 / api / breezetodo / metadata
Request Method: GET
Status Code: 401 Unauthorized
But if I am mistaken in the url (see "x" after breezetodo)
Request URL: http: // localhost: 32377 / api / breezetodox / metadata
Request Method: GET
Status Code: 404 Not Found
Same thing if my action name does not match (see "x" after metadata):
Request URL: http: // localhost: 32377 / api / breezetodo / metadatax
Request Method: GET
Status Code: 404 Not Found
In other words, HTTP cannot report that a resource is unauthorized if it cannot find this resource in the first place.
source share